Menu

Dipesh Majumdar

Blog and Paintings

vi editor tips and tricks

  1. go to top of screen
  2. go to middle of file
  3. go to end of file
  4. start inserting just above the cursor line (better than i)
  5. start inserting below the cursor line... though i rarely need this because i like to insert from above cursor line
  6. go to 9th line of job.yaml
  7. find out all occurences of the string job in job.yaml
  8. traverse word by word - forward and then backword
  9. traverse left right
  10. traverse up and down
  11. delete to end of word. but if word: the : wont be deleted so now delete complete word
  12. delete word up until next space
  13. go to a particular character say - t
  14. go back to a particular character say - T
  15. go to beginning of line and then to end of line

answers: 

  1. H (or gg)
  2. M
  3. L  (or you can do a capital G)
  4. O
  5. o
  6. vi job.yaml +9
  7. grep -in job job.yaml
  8. w for forward and b for backward
  9. h and l
  10. k and j
  11. dw  word and dW for complete word
  12. as you would all know the meaning of dd - which is to delete a line... and x - which is to delete a character... have you ever thought about as to how to delete a group of characters till a particular character. Well the answer is: dt<that_character>.... so it can be like dt<SPACE> if you want to delete till the next space character.
  13. ft
  14. fT
  15. 0 $

 

links and references:

http://www.lagmonster.org/docs/vi.html

https://www.thomas-krenn.com/en/wiki/Vi_editor_tips_and_tricks

https://www.tecmint.com/how-to-use-vi-and-vim-editor-in-linux/

https://openvim.com/

Go Back



Comment