Vim: beginning and end of the line

by George Y. Kussumoto

It's funny how small changes can improve our workflow by an order of magnitude. If you're familiar with regular expressions the ^ (beginning of the line) and $ (end of the line) is a natural metaphor to move within the line. I always felt sluggish typing those to move in the line as if they were slowing me down.

Then I found about I (insert before the first non-blank character) and A (append to end of the line). While in normal mode, after you hit one of those you will be in insert mode. It sounds like the extra keystroke required to return to normal mode is a "waste" but, at least in my case, I'm exactly where I want and ready to type some text most of the time.

After you internalize the use of those commands, they become a lot faster than the usual ^ and $. They also work in bash vim-mode (and I suppose, other shells as well) and vim's :norm, so there's a compound effect by adopting those commands.

Here's some examples:

" add ';' in the end of the line 2-5
:2,5norm A;

" prepend the first 3 lines with '- '
:1,3norm I-

Keep vimming!

~ 🤘