Gebruikershulpmiddelen

Site-hulpmiddelen


linux:vi:vi-reference

VI REFERENCE

COMMAND MODE

h j k l			move cursor left, down, up, right
3w   2b			move cursor three words forward, two words back
^    $			move cursor to beginning/end of line
G    1G			move cursor to last line/line 1
r			replace one character
J			join two lines
x    xp			delete one character; transpose two characters
dd   3dd   ddp		delete one line/three lines; transpose two lines
d^   d$			delete to beginning/end of line
dG			delete to end of file
.			repeat last change
u			undo last change
yy   5yy		yank copy of line/of five lines into temp. buffer
p    P			put contents of temp. buffer after/before current line
"a2yy			yank copy of two lines into named buffer "a
"b3dd			yank three deleted lines into named buffer "b
"ap  "bp		put contents of named buffer "a or "b after current line

FROM COMMAND MODE TO INPUT MODE

i    I			insert before cursor/at beginning of line
a    A			append after cursor/at end of line
o    O			open new line below/above cursor
cw   3cw		change word; change three words
R			replace entire line(s) ('big overstrike')

To return to command mode: use Esc

FROM COMMAND MODE TO LAST LINE MODE

:set nu   :set nonu	display line numbers; stop display of line numbers
:set all  :set list	show all option settings; display invisible characters
:w   :w	newfile		write buffer to disk; write buffer to 'newfile'
:wq  :q!		write buffer to disk and quit vi; quit vi (forced)
:1,10w nextfile		write lines 1-10 of current file out to 'nextfile'
/[Aa]nd			search forward for pattern 'And/and' with wrap around
?text			search backward for pattern 'text' with wrap around
n    N			go to next/previous occurrence of pattern
:e!			restore current file, disregarding changes
:e newfile		discard current file and edit 'newfile'
:e #			edit last file edited
:r memo			read in and insert file 'memo' at cursor position
:r !cmd			read in and insert output from UNIX command
:! lp %			print current file on default printer
:1,$s/[Aa]nd/AND/g	throughout file globally substitute pattern 'and' or
                        'And' by 'AND'

To get command performed and/or to return to command mode: use Return

.

Copyright (C) 2000 Integrated Services; Tux4u.nl
Author: Drs.M.Waldorp-Bonk; viref 20000703

linux/vi/vi-reference.txt · Laatst gewijzigd: 2018/12/30 17:17 (Externe bewerking)