Skip to content

Instantly share code, notes, and snippets.

@vheidari
Last active July 10, 2022 14:47
Show Gist options
  • Save vheidari/920c2b716c64235b2cbe3097182e9c7e to your computer and use it in GitHub Desktop.
Save vheidari/920c2b716c64235b2cbe3097182e9c7e to your computer and use it in GitHub Desktop.
Useful Vim Cheat Sheet
  1. Change to editor mode : [ i ]
  2. Chagne to viewer mode : [ esc ]
  3. Select multi line of code : [ v ]
  4. Cut multi line of code : [ x ]
  5. Past cuted or copied lines : viewer mode -> [ p ]
  6. Search and replace a word inside file : viewer mode -> [ :s/word/replace ]
  7. Search and replace a all word inside file : viewer mode -> [ :%s/word/replace ]
  8. Delete a word in viewer mode : viewer mode -> [ d ] -> [ e ]
  9. Delete multi word in viewer mode : viewer mode -> [ d ] -> [ number] -> [ e ]
  10. Delete a char in viewer mode : viewer mode -> [ d ] -> [ right arrow ]
  11. Run bash command from inside of editor -> [ :! command_name ]
    • ex : [ :! ls ]
    • ex : [ :! nasm -f elf assembly_code.asm ]
  12. Undo removed word : viewer mode -> [ u ]
  13. Move keyboard in viewer mode : viewer mode -> [ h - for left ] - [ j - for down ] - [ k - for up ] - [ l - for left ]
  14. Go to Line : viewer mode -> [ : number ]
    • ex : [ :14 ]
  15. Search for a word in editor : viewer mode -> [ /word ] -> [ enter ]
  16. To search next word : viewer mode -> [ n ]
  17. To search previous word : viewer mode -> [ shift ] + [ n ]
  18. To move to next word in viewer mode : viewer mode -> [ ctrl ] + [ right arrow] - [ ctrl ] + [ left arrow ]
  19. To save current file : viewer mode -> [ :w ]
  20. To save and exit : viewer mode -> [ :wq ]
  21. To quit file after save a file : viewer mode -> [ :q ] -> [ enter ]
  22. To quit from editor without save file : viewer mode -> [ :q! ] -> [ enter ]
  23. To quick back to bash and saw last system output : viewer bash -> [ :! ] -> [ enter ]
  24. To open a file after save current file : viewer mode -> [ :e filename ]
  25. To show list of file after using [ :e ] command : viewer moode -> [ :e first char of word] + [ tab ]

Good reference :

 https://www.keycdn.com/blog/vim-commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment