Skip to content

Instantly share code, notes, and snippets.

@simonLeary42
Last active July 11, 2026 02:40
Show Gist options
  • Select an option

  • Save simonLeary42/c44c0a8fbeb25bf156336f1379f77ad0 to your computer and use it in GitHub Desktop.

Select an option

Save simonLeary42/c44c0a8fbeb25bf156336f1379f77ad0 to your computer and use it in GitHub Desktop.
  • x - delete character
  • d... - delete motion
  • dd - delete line (or 2dd for 2 lines)
  • y... - copy motion (yank)
  • yy - yank line (or 2yy for 2 lines)
  • p / P - paste (put) (p after cursor, P before cursor)
  • u - undo
  • U - undo all changes on line
  • <C-r> - redo
  • r... replace current character
  • R enter replace mode (overtype)
  • c... change motion (delete and enter insert mode)
  • v - open visual mode
  • V - open visual line mode
  • <C-V> - select line
  • <C-v> - open visual block mode
  • o / O - insert a new line, move cursor to that line, and open insert mode
  • i / I - enter insert mode (I at beginning of line)

motions - emacs vs vim

name emacs keybind vim keybind
beginning of line C-a ^ 0
end of line C-e $
beginning of file M-< gg
end of file M-> G
specific line G + line number
beginning of next word M-f w / W
end of current word e / E
beginning of current word M-b b / B
next paragraph M-} }
previous paragraph M-{ {
previous cursor location <C-o>
next cursor location <C-i>
search C-s / / ?
next search result n
previous search result C-r N
page up C-v <C-b>
page down M-v <C-f>
scroll cursor centered C-l zz
scroll cursor top C-l zt
scroll cursor botton C-l zb

file/window/buffer mgmt - emacs vs vim

name emacs cmd emacs keybind vim cmd vim keybind
open file find-file C-x C-f :find N/A
hide everything else delete-other-windows C-x 1 :only :on <C-W>o
delete window delete-window C-x 0 :close <C-W>c
delete window delete-window C-x 0 :close <C-W>c
go to next window other-window C-x o N/A <C-W>w
split top/bottom split-window-vertically C-x 2 :split <C-W>s
split left/right split-window-horizontally C-x 3 :vsplit <C-W>v
list buffers ibuffer C-x C-b :buffers :ls N/A
open buffer switch-to-buffer C-x b :buffer :b N/A
swap to last buffer switch-to-prev-buffer N/A :b# <C-6>
equalize window sizes balance-windows C-x + N/A <C-=>

find/replace

  • :s/foo/bar/ - replace 1st occurrence on the current line of foo with bar

  • :%s/foo/bar/ - replace 1st occurrence after the cursor of foo with bar

  • :5,10s/foo/bar/ - replace 1st occurrence between lines 5 and 10 of foo with bar

  • :nohlsearch / :nohl / :noh - stop highlighting search

  • add g to handle all occurrences within the given range

  • add gc to handle all occurrences but confirm each time

  • you can also start a find/replace limited to selected text in visual mode

  • also see the R keybind for replace/overtype

other commands

  • :!ls - execute the ls command and show output in message pager
    • if there is a selection in visual mode, pass the currently selected text as stdin to the ls command and replace the selection with the command's output
  • :w !ls - pass the currently selected text (or the entire file) as stdin to the ls command and show the output as a message
  • :w PATH_HERE - write the contents of the open buffer to a file located at PATH_HERE
    • you can also write a specific text selection from visual mode
  • :q - quit
  • :r - insert a file's contents
    • :r !ls - insert the output of the ls command

options

  • usage: :set OPTION_NAME_HERE
  • note: prepend option with no to turn off
  • note: prepend option with inv to invert (toggle)
  • ignorecase / ic
  • hlsearch / hls
  • incsearch / is
  • number / nu

help

  • C-d - show tabulated command completion options

show keybind for a given command

  • emacs: where-is / C-h w
  • nvim:
    • if builtin keybind: help index and then grep
    • else (mapped): :new, :put =execute('COMMAND_HERE'), (where COMMAND is nmap / imap / vmap depending on mode or map for all modes) and then grep

show command for a given keybind

  • emacs: describe-key / C-h k
  • nvim:
    • if builtin keybind: :help KEYBIND_HERE (example: CTRL-W_w)
    • else (mapped): :verbose map KEYBIND_HERE (example: <C-W>w)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment