Skip to content

Instantly share code, notes, and snippets.

@m0hadang
Last active January 25, 2026 02:30
Show Gist options
  • Select an option

  • Save m0hadang/7875d4d8ddbcc672375d3a007b0dc5e6 to your computer and use it in GitHub Desktop.

Select an option

Save m0hadang/7875d4d8ddbcc672375d3a007b0dc5e6 to your computer and use it in GitHub Desktop.
vim shortcut

vim shortcut

cursor tracking

  • ctrl + o : go to the previous (older) location in the jump list.
  • ctrl + i : go to the next (newer) location in the jump list.Z
  • %(shift + 5) : start/end of current scope
  • ^(shift + 6) : home
  • $(shift + 4) : end
  • number + k : move up number lines
  • number + j : move down number lines
  • number + G : go to line number
  • W or B : jump word

select

  • V : select line
  • V + i + { : select inner block
  • V + { or } : select block until next blank

delete

  • d + a + { or } or B : delete a curly brace block

goto

  • g + d : goto definition
  • g + f : goto file path
  • % : goto current brace, switch brace

modify

  • . : repeat last insert command
  • shift + j : join lines together
  • Ctrl + a : increment number selected
  • Ctrl + x : decrement number selected
  • s : switch current character and move to begin and modify continue
  • S : switch current line and move to begin and modify continue
  • V + C : switch selected line and move to begin and modify continue
  • R : continuously replace
  • :%s/foo/bar/g : replace all
  • ~ : Change case of selection

match

  • {action} => d or c or v or y
  • {contain_braces} => a or i
    • a : contain braces
    • i : not contain braces
  • {action} + {contain_braces} + {braces} : find first braces and action
    • d or c or s : only braces
    • D or C os S : contain name
  • {action} + i + w : find current word and action
  • {action} + {contain_braces} + b : find current scope and action
  • {action} + {contain_braces} + i : find first phase and action
  • y + i + ( : copy argument
    • fn get_md_files(dir: &str) -> Vec<String> {
    • fn get_md_files(dir: &str* <-- at this position
  • y + i + ) : copy argument
    • fn get_md_files(dir: &str) -> Vec<String> {
    • at this point->*dir: &str) -> Vec<String> {

find

  • f + {char} : find first forward match character

    • ex: f + '{' or '}' or '(' or ')'
  • F + {char} : find first backward match character

      • n or N : find word forward/backward

window

  • :hsplit or :sp : split the window horizontally.
  • :vsplit or :vs : split the window vertically.
  • Ctrl + w :starts Window mode that let's you move or create splits.
    • h or j or k or l
    • w : switch
  • K : show man page about current word

pattern

  • v + a + D
  • :! {shell_command} : run shell command
    • ex)
      • :! date
      • :! ls
      • :! cargo build
  • :te : run terminal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment