How to Code with vim
Switch lines
- Step 1: Position the cursor on the line you want to move.
- Step 2: Type
dd
to cut the entire line. - Step 3: Move the cursor to the desired position.
- Step 4: Type
p
to paste the line below the current line, or typeP
to paste the line above the current line.
Example:
- To move line 2 to line 4:
- Navigate to line 2.
- Type
dd
(line is cut). - Navigate to line 4.
- Type
p
(line is pasted below line 4).
Save the file
- Step 1:press "esc"
- Step 2: Type "
:w"
,to write changes. - Step 3: Type "
:wq"
, to write and quit.
Undo
- Step 1:press "esc"
- Step 2: Type "
:u"
Comments
Post a Comment