Monday, April 28, 2014

Vim Editor Commands

Vim ?? What's that ??

 











Vim is an editor to create or edit a text file.
 
There are three modes in vim.
  • Insert mode - Adding text
  • Command mode - Modifying text
  • Last line mode - Save & quit

Insert Mode:

Changing mode from one to another
From command mode to insert mode type a/A/i/I/o/O ( see details below)
From insert mode to command mode type Esc (escape key).


Command Mode:

  1. yy - to copy a line. 
  2. yw - to copy a word. 
  3. yl - to copy a letter. 
  4. dd - to delete a line. 
  5. dw - to delete a word. 
  6. dl - to delete a letter. 
  7. x - to delete a letter. 
  8. D - to delete from cursor location towards end of line. 
  9. cc - to cut a line. 
  10. cw - to cut a word. 
  11. cl - to cut a letter. 
  12. p - to paste below the cursor. 
  13. P - to paste above the cursor. 
  14. u - to undo the changes. 
  15. ctrl + r - to redo the changes. 
  16. G - goto last line of the file. 
  17. gg - goto first line of the file. 
  18. /string - forward search for text. 
  19. ?string - backward search for text. 
  20. zz -  to save & quit. 
  21. d) - delete from cursor location towards end of the file. 
  22. d(  - delete from cursor location towards start of the file.
  23. e - goto end of next word.
  24. b - goto start of previous word.
  25. n - search.


Last Line Mode:

  1. noh - to remove text highlight.
  2. wq / x - save & quit.
  3. wq! / x! - save & quit forcefully.
  4. q - quit.
  5. q! - quit forcefully.
  6. w - to save.
  7. w! - save forcefully.
  8. set nu - to set numbers.
  9. set nonu - to remove numbers.
  10. !pwd - to know path.
  11. !tty - to know terminal.
  12. :w anyname - for save as.
  13. :set ic - search case sensitive.
  14. :set noic - ignores case sensitive.
  15. vim + line number filename - search and go to specific line.
  16. vim + /string filename - search and go to specific string.
  17. vim -o file1 file 2 - modify two files.
  18. nl filename - indicates number lines. 


                                         Short Description Video - Vim Editor command






By Linux-Care



Related Posts:

  • vim vim command examples Go to the 143rd line of file $ vim +143 filename.txt Go to the first match of the specified $ vim +/search-term filename.txt Open the file in read only mode. $ vim -R /etc/passwd   &nb… Read More
  • unzip unzip command examples To extract a *.zip compressed file: $ unzip test.zip View the contents of *.zip file (Without unzipping it): $ unzip -l jasper.zip Archive:  jasper.zip   Length  &… Read More
  • top   top command examples top command displays the top processes in the system ( by default sorted by cpu usage ). To sort top output by any column, Press O (upper-case O) , which will display all the possible columns… Read More
  • tail   tail command example Print the last 10 lines of a file by default. $ tail filename.txt Print N number of lines from the file named filename.txt $ tail -n N filename.txt View the content of the file in real… Read More
  • uname   uname command examples Uname command displays important information about the system such as — Kernel name, Host name, Kernel release number, Processor type, etc., Sample uname output from a Ubuntu laptop is … Read More

2 comments: