It’s just yulistic!

Vim tips

· by yulistic · Read in about 2 min · (220 Words)
  1. divide window

    • [Ctrl] + w  v => split vertically.

    • [Ctrl] + w  s => split horizontally.

    • :vs filename => split vertically and open file.

    • :sp filename => split horizontally and ope file.

    • :qa close all windows.

    • (in shell) vim -o txt.a txt.b => open txt.a and txt.b in two windows split horizontally.

    • (in shell) vim -O txt.a txt.b => open txt.a and txt.b in two windows split vertically.

    1. tab
    • :tabnew filename => open file in a new tab.

    • [Ctrl] + [Page Up/Down] => move to the other tab.

    • :tabn => go to next tab.

    • :tabp => go to previous tab.

    • (in shell) vim -p txt.a txt.b txt.c => open txt.a, txt.b, and txt.c in three respective tabs.

    1. go to file
    • gf => go to file under the cursor.

    • [Ctrl] + ^ => go back to the previous file.

    • :find filename => find and go to the file.

    • :tabf filename => find and open the file in a new tab.

    1. Plug-ins

    2. Auto Close(link): Insert parentheses automatically.

      • Install: Download autoclose.vim from web site and save into ~/.vim/plugin directory.
    3. NERD commenter(link): Toggle comment.

      • Install: Download file, unzip and move it to ~/.vim directory(~/.vim/doc and ~/.vim/plugin).

      • Usage:

      1. Select lines with visual block

      2. [] + c + [Space] : Toggle comment.

      3. [] + c + [a] : Change comment style (e.g. «/* */» <-> «//»)

Comments