Saturday, July 14, 2012

Linux 16 - Basic File editing with VI

VI

- press I to insert
- press O to insert to next line
- press :! command to execute a command inside VI
- enter numbers and then dd to delete lines
    - for intance to delete 17 lines type 17 in command mode and then dd
- to delete characters instead of dd type x
- yy copies the line
- A inserts after the cursor
- p pastes the copied line
- ESC goes back in command mode
- H, J, K, L, for left, down, up, right
- command mode = work with text in vi
- dl is cut the letter
- dw is cut the word after the cursor
- dd is to cut the entire line

Find stuff:
- press / type the word you are looking for
- to go to next found item press n
- to go to the last found item press N

- press ?

 

To revert the edits:

-:e!

To save:

-:w will write to file
-:w newfile.txt

Quit:

-:q
-:q!

Write and Quit:

-ZZ
-:wq

 

 

 

 


No comments:

Post a Comment