Saturday, 22 November 2014

Editing files in vi

Backspace
Delete the character before the cursor
Del
Delete the character under the cursor
i
To insert text under the cursor(insert mode)
I
To insert text under the cursor starting from the beginning of the current line(insert mode)
a
Insert starting after current character.

A
Insert starting at the end of the line after the last character.

cc
 Delete the entire line and go into insert mode.

C
 Delete to the end of line and go to insert mode.

cw
Delete the current word and go into insert mode.

Y
Yank (copy current line to buffer). If you give this a number before it, it will “yank” the specified
number of lines after the cursor (including current line the cursor is on). Many commands also
have this enumerated functionality
dd
Delete (cut) the current line. Can be enumerated.
dw
Delete (cut) the current word. Can be enumerated.
D
Delete the current line (But leave the new line)
J
Join the next line with the current line.
o
 Insert after the current line.
O
Insert before the current line.
p
Put (paste) the lines in the buffer (from Y, dd, or x) after the current line. Can be enumerated.
P
 Put (paste) the lines in the buffer before the current line. Can be enumerated.
rc
Overwrite with character c, replace the current character.
R
Change to replace (overwrite) mode.
s
 Delete the current character and go to insert mode.
S
 Delete the current line and go to insert mode.
u
 Undo the last operation.
U
 Switch between undoing and redoing the last edit.
v
Visual: start the selection for a “d” (delete) or “Y” (yank). Type “v”, then move in a direction
using one of the movement keys to see what you have selected.
V
 Visual line: select the current line for delete or Yank.
x
 Delete (cut) the character under the cursor. Can be enumerated.
X
Delete (cut) the character after the cursor. Can be enumerated.
~
 Capitalize the current character.
= =
 Unindent the current line (type the equal sign twice).
.
Repeat the last command.
F1
Display only help

No comments:

Post a Comment