Vi

Some hints and tips for vi/vim.

Simple edition

  • Go to line NNN
:NNN
  • Cut NNN lines
NNNdd
  • Copy NNN lines
NNNyy
  • Paste
p
  • Undo
u
  • Redo
CTRL+r
  • Repeat last modification
.

Search and replace

  • replace a word :
cw
  • Search/Replace : the following line replace string1 to string2 between linges start and end (1,$ modify all the doc)
start,end s/string1/string2/g 

Save/Quit

  • save
:w
  • save & quit
:x
:wq
  • quit without saving
:q!

Advanced

  • Disable auto indentation (useful when pasting text block) :
:set noai
:set noautoindent
  • File conversion
:set ff=unix
:set encoding=utf-8
:set fileencoding=utf-8

Links

en/linux/vi.txt · Last modified: 2011/01/08 14:31 by matthieu
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki