Vim tips

inglese
http://lucasoman.blogspot.com/2008/07/vim-tips-part-1.html

Tips per usare al meglio Vim

Navigation

    * h, j, k and l - Move left, down, up, or right.
 
    * gg and G - Move to the top or the bottom of the file.
 
    * ctrl-u and ctrl-d - Move up or down one half-screen.
 
    * w and b - Move forward or backward, one word at a time.
 
    * fX, FX - Move the cursor over the next or previous occurrence of X in the current line, where X is any character.
 
    * tX, TX - Move the cursor to (not over!) the next or previous occurrence of X in the current line.
 
    * 0 and $ - Move the cursor to the beginning or end of the line.
 
    * ^ - Move the cursor to the first non-whitespace character of the line.
 
    * /[string] and ?[string] - Searches forward or backward for [string].

Tabs

I love tabs. They're a new feature in Vim 7, and I instantly became dependent on them. Here are the commands for using them:

    * :tabe [file] - Open a new tab editing [file]. Don't specify [file] to open a blank tab.
 
    * gt and gT - Move to the next or the previous tab. If already at the last or first tab, wraps
      around.
    * Ngt - Move to the Nth tab.
 
    * :q - Closes current tab.
 
    * :qa - Closes all tabs and exits Vim.

Editing

    * d - Deletes in the direction of your movement. E.g.: d$ deletes to the end of the line, dw deletes to the end of the current 
       word, dF[ deletes backward to and including the next '[' character.
 
    * dd - Deletes current line.
 
    * rX - Replaces current character with character X.
 
    * ~ - Toggles capitalization of current character. If in visual mode, toggles capitalization of highlighted block.
 
    * s - Deletes current character and enters insert mode.
 
    * i - Enters insert mode.
 
    * a - Moves one character forward and enters insert mode.

Folding

Folding is incredibly useful. It's great for getting large blocks of code out of your way in annoyingly long class files.

    * zf[movement] - Folds lines in direction of [movement]. E.g.: zfG folds all lines from the current line to the end of the file. 
       For [movement], you can also use text objects.
 
    * zf - In Visual mode, will fold the currently selected lines.
 
    * zo - Open the fold under the cursor.
 
    * zc - Close the fold the cursor is in.

Other Tips

    * :% - Replaced by current file. You'll see how this is useful below.
 
    * :![command] - Execute [command] in the shell. E.g.: !php % - runs current PHP script, !ls - lists files in current directory, 
       !php -l % - checks syntax of current PHP script, !cp % %.bak - creates a backup of current file.
 
    * :nohl - Turns off highlighting, if it's on. Depending on your Vim's configuration, doing searches (with / and ?) highlight all 
       matches.
       This will un-highlight all search matches.

Per altri tips: http://lucasoman.blogspot.com/search?q=vim

I love tabs. They're a new feature in Vim 7, and I instantly became dependent on them.