One of my non-technical coworkers recently came by my desk with a problem - she had [this list] of zip codes in Long Island, and needed me to write a SQL query to fetch a list of users who had zip codes in that list.Read more →
In case it’s not obvious at this point, I really, really like vim. I like it so
much, in fact, that any time I’m editing text and I can’t use vim I end up
spending about half my time pulling my hair out and cursing loudly at the
computer. To get around this, I’ve managed to inject it into about everything I
do. I use i3 as my window manager, configured so that I can
move, resize, and switch between all my windows using Vim cursor keys. I use
pentadactyl in firefox, which revamps the
whole user interface so that everything can be done using Vim commands and
shortcuts. And I
set -o vi in my shell so that I can edit command line
commands using Vim keys.
Another thing I do to make it so I never have to use anything that isn’t vim is edit all temporary SQL commands in vim, and run them all from there. This allows me to run SQL statements directly from code, and also to use the output to help me write the code itself (see my post about the vim substitute command for an example). To accomplish this, I use the vim-pipe plugin by krisajenkins. Here’s how to get that set up, and also some tips and tricks on how to use it best.Read more →
I know a lot of people who use Vim as a sort of glorified console-mode notepad. They
write a bunch of things twice, have a tendency to mash backspace when they made a typo
earlier on the line, and perform a lot of very repetitive actions to modify code. Even if
you’re being a “good vim user” and using
hjkl instead of cursor keys, if you frequently
find yourself doing the same thing twice then you’re really not taking advantage of the
full power that Vim has to offer.
:substitute command is an awesome way to get rid of a lot of that repetition. Though
it may seem like just a find and replace command it packs a full regex engine, which with
references to numbered groups means you can rearrange and reorganize lines of code to your
liking. Let’s take a look at an example of a use case I just encountered the other day.