Vi is a powerful text editing tool that can be used quickly and efficiently to alter files, scripts, etc. Below are some useful cheat sheet commands for vi to speed up text editing:
Move commands
$ - move to end of line
0 - move to beginning of line
G - move to last line of file
1G - move to first line of file
h - move cursor left
l - move cursor right
k - move cursor up
j - move cursor down
w - move to next word
W - move to next blank delimited word
b - move to beginning of the word
B - move to beginning of blank delimited word
H - move to top of the screen
M - move to middle of the screen
L - move to bottom of the screen
Replace text commands
cw - change word
r - replace letter
R - replace until [esc] is pressed
C - change to the end of the line
cc - change the entire line
Insert text commands
i - insert before cursor
I - insert before line
a - append before cursor
A - append before line
O - insert line above current line
o - insert line below current line
yy - yank line
y$ - yank from current position to end of line
p - put yanked text after cursor
P - put yanked text before cursor
[shift] + [insert] - insert text saved in clipboard
Delete text commands
dd - delete entire line
x - delete character to the right of the cursor
X - delete character to the left of the cursor
D - delete to the end of the line
File commands
:qw - quit and save
:w - save
:q! - quit without saving
Search Commands
/string - Search forward for string
?string - Search backward for string
n - Search for next instance of string
N - Search for previous instance of string
other commands
~ - toggle between upper and lower case
J - join lines
. - repeat last text-changing command
u - undo last change
U - undo all changes to line
No comments:
Post a Comment
Please feel free to leave a comment