Skip to content

Instantly share code, notes, and snippets.

@vuongpd95
Last active November 26, 2021 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vuongpd95/997d1a14774dfe428ff808dd04a1d6fd to your computer and use it in GitHub Desktop.
Save vuongpd95/997d1a14774dfe428ff808dd04a1d6fd to your computer and use it in GitHub Desktop.
My Vim essentials

My Vim Essentials

Those are the commands which I frequently use & feel it effective & easy.

Working with .vimrc, Vundle

  • :source % to reload vimrc
  • :PluginInstall to install plugin using Vundle

Navigations

Line navigation

  • ^ – goes to the start of line, remains in command mode.
  • I – (uppercase i) goes to the start of line, switches to insert mode
  • $ – go to the end of the current line, remains in command mode, newline character are included.
  • A – goes to the end of the current line, switches to insert mode.
  • G – goes to the final line of the file.

Word navigation

  • e – go to the end of the current word.
  • E – go to the end of the current WORD.
  • b – go to the previous (before) word.
  • B – go to the previous (before) WORD.
  • w – go to the next word.
  • W – go to the next WORD.

Paragraph navigation

  • { – Go to the beginning of the current paragraph. By pressing { again and again move to the previous paragraph beginnings.
  • } – Go to the end of the current paragraph. By pressing } again and again move to the next paragraph end, and again.

References:

Tmux

  • ctr + B " to split horizontally.
  • ctr + B % to split vertically.

Uncategorized

Reload Vimrc (or any files) without reopen the file

:source ~/.vimrc

NERDTree

  • :NERDTreeFind to switch to the NERDTree and find the file of the current buffer.
  • :NERDTree to open a new NERDTree.
  • P to jump to the NERDTree root, cd to change CWD to the NERDTree root.
  • :Bookmark <name> to create a bookmark at the current directory
  • :ClearBookmark <name> to delete a bookmark

Regular VIM commands

  • Shift + $ to go to the last character of the line.
  • Shift + ^ to go to the first character of the line.
  • :bufdo <command> to perform a command on all quick fix buffers.
  • Use :cfdo <command> to run a command on all quick fix files.
  • We can pipe commands while using :cfdo too, for example: :cfdo %s/pattern/replacement/g|w
  • Use :cw to open quick fix buffer.

FZF

  • :Files to open the search terminal for files (Start at the directory of CWD).
  • In :Files search terminal, use Tab to add files to quick fix and Enter to open quick fix window.

Multi-cursor (using Visual Multi vim plugin)

  • To quickly replace all similar appearances of a sentence in a file.
    • Select the sentence using Visual Mode.
    • Ctrl + N will find all of the sentence appearances.
    • N to select all appearances.
    • d to delete all appearances.
    • i to start typing at every places you have deleted the sentence.
    • ESC to escape from the insert mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment