Saturday 8 February 2014

Basic commands for the Linux vi Editor

vi is a powerful screen oriented text editor for Linux/Unix operating system, that's why very useful for file handling mainly in the field of computational biology. Please download printable version here

*** Some Basic vi Commands *** 

For editing the file

1. vi filename  [create or edit file]

2. vi -r filename [recover the filename that was being edited]

3. Esc i [for inserting text]

4. Esc I [inserting text at the beginning of the current line]

5. Esc o [open and put a text in a new line below current line]

6. Esc O [open and put a text in a new line above current line]

7. Esc colon wq [for save and quit]

8. Esc colon q! [for quit only not for save]

9. Esc u [for undo whatever you just did]

10. Esc $ [move cursor to the end of the current line]

11. arrow keys for move up (k), down (j), left (h) and right (l)

12. :s/findme/replaceme/g [for finding and replacing with particular character/word]

For deleting the text

1. Esc x [delete single character under the cursor if Nx means N number of characters]

2. Esc dw [delete the single word beginning with character under cursor if dNw same as previous]

3. dd [delete entire current line, if Ndd same delete N lines beginning with the current line]

For copy paste

4. yy [copy the current line]

5. p [paste the line]

for more information you can type vi -h 

*******   The end ******

No comments:

Post a Comment