Move :
h left one character
l right one character
k up one line
j down one line
b back one word
f forward one word
{ up one paragraph
} down one paragraph
$ to end of the line
^B back one page
^F forward one page
17G to line #17
G to the last line
Insert :
i just before the current cursor position
a just after the current cursor position
o into a new line below current cursor
I at the beginning of the current line
A at the end of the current line
O into a new line above current cursor
search : /
replace : r, R
replace (global) : %s/old/new/g
change : c, C
>> Copy current line yy or Y
>> Copy a word yw
>> Copy 4 words y4w or 4yw
>> Paste after cursor p
>> Paste before cursor P
>> Move current line after line 5 :m 5
>> Move line x after line 5 :xt 5
>> Move line 9 after line 5 :9t 5
>> Undo last modification u
>> Undo all changes on a given line U
>> Global search and replace --> :1,$ s/old/new/g
>> Insert file at cursor position --> :r filename
Capitalize the first letter of each word from line #26 through the end of the file --> :26,$s/\<[a-z]/\U&/g Multi file editing
vi can manipulate more than one file at the same time, therefore to edit three files in sequence, type: vi one two three
To detect which file is currently edited use the ex ar
(args) command: :ar
that types file list and flags current file at screen bottom as follows: one [two] three
:w | write file with the following message at screen bottom: |
"vi_ex.doc" 670 lines, 27747 chars | |
ZZ | terminate current editing with the following message at screen bottom: |
2 more files to edit |
To move along files in the list:
vi Multifile Moving Commands | |
:n | edit next file in the list |
: Nn | advance n files in the list |
| toggle between the two last files |
:e# | reopen previous file, same as above |
e file | re-edit from disk |
:rew | rewind file pointer to first file |
:rew! | force rewind and immediatly reopen first file |
:ar | list file names |
No comments:
Post a Comment