Moving Around in the file
Ctrl-b
Moves backwards a page.
Ctrl-d
Scrolls down half a page
Ctrl-f
Moves forward a page
Ctrl-l
Refresh the screen
Ctrl-u
Scrolls up half a page
b
Moves the cursor back one word
e
Advances the cursor to the end of the current word
G
Moves the cursor to the end of file.
h,j,k,l
Moves the cursor one space left,down,up,right
(#)G
Moves the cursor to the line number (#)
0
Moves the cursor to the start of the current line.
w
Next word
)
Next sentence
(
Previous sentence
^
Beginning of current line
$
End of currentl line
%
Match brace or parenthesis
Text input commands
a
Append
A
Append to end of line
i
Inserts before cursor
I
Insert at the beginning of line
o
Open empty line after current one
O
Open empty line before current one
Editing commands
cc
Changes line until ESC
cw
Changes word until ESC, End of word is flagged by $.
dd
Delete line
dw
Delete word
d)
Deletes rest of sentence
d}
Deletes rest of paragraph
D or d$
Deletes to end of line
J
Join next line to current line
r
Replaces the char the cursor is on
R
Writes over old text
s
Substitute character with text and keep inserting until ESC
x
Deletes a char
:r file
Reads in a file from where cursor is
:r !command
Reads in the results of command
:s/string1/string2
Substitutes string1 for string2 in current line
$s/string1/string2/g
Substitute all string1 with string2 in the whole file.
Cut/Copy and paste commands
p
Puts last text yanked or deleted after cursor.
P
Paste yanked text before cursor.
yw
Yank a copy of the word from cursor.
yy
Yank a copy of a line.
y)
Yank to end of the sentence.
y}
Yank to end of paragraph.
y$
Yank to end of line.
y3w
Yank next 3 words.
Search commands
n
Continue searching in the same direction. Use with :s or / c......
N
Search in the opposite direction
?(word)
Search for (word) backwards in the text before the cursor.
/(word)
Search for (word) afterwards in the text before the cursor.
Undo /repeat
u
Undoes the last command
U
Undoes all changes made to the current line
.
Repeats the last editing or insert command
Write commands
:q
Quits and leaves the editor
:q!
Forces exit without saving changes.
:w
writes and save the file.
:w (name)
Writes to new file (name)
:wq
Write and quite
:.,$w (name)
Writes rest of current file to (name)
:x
Same as :wq
ZZ
Same as :wq
No comments:
Post a Comment