Adventures in vim

Forgot to mention — if this is all Greek to you, don’t worry! I’ve been learning from fellow Vim users and sharing tips since the late 1990s. Give it time; it will come.

Following up on last time — you can also use motions like ip with : commands that normally take ranges.

Type v<motion>, where <motion> is ip or G or some other cursor motion command. Vim will highlight the text from the cursor to wherever <motion> takes you. (If only vim had a motion key for second star to the right and straight on ’til morning!) You can then issue any : command and it will operate on the selected text.

I often use external sort or fold utilities via filter commands. Those are even easier – you don’t even have to type the :. For example, vip!fold -s -w 70<Enter> folds long lines in the current paragraph. Sure beats what I used to do, which was {:.,/^$/!fold -s -w 70<Enter>! (Makes total sense, right? 🙂 )

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s