Skip to content

Instantly share code, notes, and snippets.

@lorn
Last active August 29, 2015 14:04
Show Gist options
  • Save lorn/5ce8264cb15cf1b75e2c to your computer and use it in GitHub Desktop.
Save lorn/5ce8264cb15cf1b75e2c to your computer and use it in GitHub Desktop.
vim tips

janelas e buffers

:sp filename for a horizontal split

:vsp filename or :vs filename for a vertical split

Edições simples

começo da linha = 0 fim da linha = $

andar para frente por palavra - w/W andar para tras por palavra - b/B

Cltr+R - redo Cltr+F/B pageup/pagedown

dev stuff

identação

seleciona bloco com shift+v, depois = seleciona com shift+v + shift > / < para "andar" com o bloco selecionado

comentar bloco

Ctrl+V seleciona bloco, depois SHIFT + i + # + ESC Também server para escrever qualquer coisa no começo do bloco

descomentar bloco

Mesmo principio, só que agora vc deleta os # com X Ctrl+V, seleciona, x

misc

dos2unix

Change the lineendings in the view:

:e ++ff=dos
:e ++ff=mac
:e ++ff=unix

This can also be used as saving operation (:w alone will not save using the lineendings you see on screen):

:w ++ff=dos
:w ++ff=mac
:w ++ff=unix

And you can use it from the command-line:

for file in $(ls *cpp)
do 
  vi +':w ++ff=unix' +':q' ${file}
done

iso => utf8

:write ++enc=utf-8 russian.txt

http://vimdoc.sourceforge.net/htmldoc/usr_45.html#45.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment