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:

  • bzip2 bzip2 command examples To create a *.bz2 compressed file:   $ bzip2 test.txt To uncompress a *.bz2 file: bzip2 -d test.txt.bz2 Normal 0 false false false … Read More
  • cd cd command examples Use “cd -” to toggle between the last two directories Use “shopt -s cdspell” to automatically correct mistyped directory names on cd Normal 0 false false false EN-IN… Read More
  • awk v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} awk command examples  Remove duplicate lines using awk… Read More
  • cp cp command examples   Copy file1 to file2 preserving the mode, ownership and timestamp. $ cp -p file1 file2 Copy file1 to file2. if file2 exists prompt for confirmation before overwritting it. … Read More
  • crontab crontab command example View crontab entry for a specific user  # crontab -u linuxcare -l Schedule a cron job every 10 minutes. */10 * * * * /home/linuxcare/check-disk-space More crontab ex… Read More

2 comments: