New Location

My website has moved to http://www.jasonwhaley.com. Please visit there for the latest and only remain here for legacy content.

Wednesday, May 26, 2010

Periodically VIM - gf (Goto File)

[Periodically VIM is my regular VIM tips and discoveries section, inspired by what was Daily VIM]

The Tip: gf will open the file name underneath the cursor.

Usage: Place your cursor on a piece of text or with a piece of text highlighted in visual mode where the text represents the path to a file name. use the command gf to open the file in the current buffer, ctrl-w f to open the file in a new window, or ctrl-w gf to open the file in a new tab.

What Is It Good For?: Fairly often, files will contain references to other files. Use this to quickly open those files without relying on having NERDTree running or by going to command mode to open the file.

Thursday, May 13, 2010

Periodically VIM - V (line base visual mode)

[Periodically VIM is my regular VIM tips and discoveries section, inspired by what was Daily VIM]

The Tip: V puts you in visual mode but works line-by-line instead of character by character.

Usage: With your cursor anywhere on a line or if you are already in character by character visual mode via v, type V and you'll be placed in visual mode on a line by line basis.

What Is It Good For?: If you need to select blocks of text for a whole line, to perform an action against that block and you didn't start at the beginning of the line, this is a useful, one-stroke way to select that whole line or lines in visual mode.

Monday, May 3, 2010

Periodically VIM - iw (inner word)

[Periodically VIM is my regular VIM tips and discoveries section, inspired by what was Daily VIM]

The Tip: iw can be used either in Visual Mode or after an operator to select or perform an operation on the entire word, regardless of where your cursor is within the word.

Usage: For visual mode, place your cursor on a word and hit the keystrokes viw or just iw if you were already in visual mode and selecting a block of text. For other commands, just place your cursor on a word and use the keystrokes Xiw, where X in this case is the operation you want. E.g.: diw deletes the word your cursor is presently under.

What Is It Good For?: Save yourself some of the keystrokes you'd make hitting h and l to move to the beginning of the word before performing an operation on it and just type your operation followed by iw.