Vim: Insert Mode is Like the Passing Lane

Insert mode is not the mode for editing text. It is a mode for editing text, because both normal and insert modes are modes for editing text. Insert mode, however, is the mode for inserting new/raw text directly from the keyboard (as opposed to, e.g., from a register or a file). Thus, you will only be in insert mode when you are actually typing in inserting (raw) text directly. For almost every other editing operation, normal mode is where you will be.

Read more

From Acolyte to Adept: The Next Step After NOP-ing Arrow Keys in Vim

We all know about no-op’ing arrow keys in Vim to get us to break the habit of relying on them for inefficient movement. But, as this post points out, it is not the location of the arrow keys that makes them inefficient, but the modality of the movement: single steps in insert mode is a horrible way to move around when normal mode provides so much better functionality.

Read more

Setting up the Text Editor in My Computing Ecosystem

Image from WikiMedia Commons Basic Setup of Shell to Support My Text Editor Preferences By “text editor”, I mean Vim, of course. There are pseudo-operating systems that include rudimentary text-editing capabilities (e.g. Emacs), and integrated development environments that allow for editing of text, but there really is only one text editor that deserves the title of “text editor“: Vim, that magical mind-reading mustang that carries out textual mogrifications with surgical precision and zen-like elegance.

Read more

Smart (`infercase`) Dictionary Completions in Vim While Preserving Your Preferred `ignorecase` Settings

Dictionary completions in Vim can use a ‘infer case’ mode, where, e.g., “Probab” will correctly autocomplete to, e.g., “Probability”, even though the entry in the dictionary might be in a different case. The problem is that this mode only works if ignorecase is on. And sometimes, we want one (infercase) but not the other (ignorecase). The following function, if added to your “\~/.vimrc”, sets it up so that ignorecase is forced on when dictionary completions are invoked via the `` keys, and then restored to its original state when exiting.

Read more

Building MacVim Natively on OS X 10.7 and Higher

You might want to do this if you want to install the latest snapshot and no pre-built release is available. OR you might want MacVim to use a custom Python installation instead of the default one on the system path. This latter was my motivation. Once you have downloaded and unpacked the code base that you want to build, step into the `src/` subdirectory: $ cd src Before proceeding, make sure that your Python installations have been built with the “``--enable-shared``”!

Read more

Some Vim Movement Tips

Within-line character-based movement: h and l move you left and right one character, respectively. f[c] or F[c] will take you forward to the next or back to the previous, respectively, occurrence of character “[c] on the current line (e.g.,fpwill jump you forward to the next occurrence of "p" on the line, whileFp` will jump you back to the previous occurrence of “p” on the line). t[c] or T[c] will take you forward to just before the next or back to just after the previous, respectively, occurrence of character “[c]` on the current line.

Read more

Vim Regular Expression Special Characters: To Escape or Not To Escape

Vim’s regular expression dialect is distinct from many of the other more popular ones out there today (and actually predates them). One of the dialect differences that always leaves me fumbling has to do with which special characters need to be escaped. Vim does have a special “very magic” mode (that is activated by “\v” in the regular expression) that makes thing very clean and simple in this regard: only letters, numbers and underscores are treated as literals without escaping.

Read more

The Power and Precision of Vim's Text Objects: Efficent, Elegant, Awesome.

Vim’s text objects are not only a powerful, flexible and precise way to specify a region of text, but also intuitive and efficient. They can be used with any command that can be combined with a motion (e.g., “d”, “y”, “v”, “r”), but in this post I will be using the “c” command (“change”) to illustrate them. Imagine you were on a line looked like this, with the cursor on the letter “r” of the word “dry”:

Read more