This short post lists the Neovim (Vim) shortcuts I am getting used to. I’ve recently switched to trying the Vim mode for my IDE needs, and having used Vim previously only for very simple tasks, am having a blast practising the basic Vim shortcuts. Ultimately, I will probably move to doing more IDE-related work in native Vim too.
I’ve also added TMux shortcuts because I’m learning to use that too.
Vim commands
u/<C-r>: Undo/Redo.: Repeat last commandw/b: Move forward/backward by a wordsrefers to a sentence. Thusdiwanddawdeletes a sentence from anywhere inside it, and everything around the sentence, respectively.(/): Jump to previous/next sentencei/a/I/A: Start editing before/after cursor, before start/after end of linei: Considers whitespace as words too, soi2wselects a word and any whitespace after it.a: Considers word + whitespace as a text object, soa2wselects"text1 text2 ".
0/_/$: Go to starting character / starting non-whitespace character / end of lined: Delete (suffix with counter and text object, liked2w,dd)c: Change (suffix with counter and text object, likec2w,cc)r: Replace (suffix with counter and text object, liker2w,rr)y: Yank (suffix with counter and text object, likey2w,yy)- Interesting Use Case:
ny$yanks from cursor to end of linentimes, sonlines, starting from the current cursor position.
- Interesting Use Case:
F-x/f-x: Find characterxbefore/after*: Search forward word under cursor/and?: Find string forward/backwardP/p: Paste before/after cursorx: Delete character under cursornG/ngg: Go to line numbernG: Go to end of filei: “Everything inside” qualifier used in conjunction with other verbs, likediw,ci"<C-v>: Visual Block Mode, useIto insert en-masse<C-o>/<C-i>: Go to old/new positions<C-u>/<C-d>: Move up/down half a page{/}: Jump forward/back across a contiguous block of text+/-: Jump to start of next/previous line
Ex commands
x,y<Command>z: Defines an inclusive range of lines fromxtoyand performs<Command>with optional argumentz.m/t: Move/Copy range of lines to afterz. Example:10,20m30. Single line variants like10m30also work.
x;+/-n: Defines range of+/-nstarting from linex.,.+/-n: Refers to the current line / Refers tonlines after/before current line.$,$+/-n: Refers to the last line of the document (Compare to going to last character in line in Vim’s Normal mode).+/-nnavigatesnlines after/before last line.%: Refers to all lines (same as1,$)/pattern/and?pattern?: Searches forward and backward forpattern. This can be used as a location argument in other commands.:<C-p>/:<C-n>: Moves backwards/forwards through command history.
TMux commands
<C-b>?: View all keybindings<C-b>%: Horizontal split<C-b>": Vertical split<C-b><Arrow Keys>: Moves across TMux panes<C-b>d: Detaches from current TMux session<C-b>[: Enables scroll mode<C-b><Space>: Enables highlight mode after entering scroll mode. Press<C-b>to yank highlighted text.<C-b>]: Pastes copied content to another TMux terminaltmux ls: Lists running TMux sessionstmux attach -t <SessionID>: Attaches to specified TMux sessiontmux rename-session -t <OldSessionID> <NewSessionID>: Renames a TMux session<C-b>,: Renames current windowtmux new -s <SessionID>: Creates a new TMux session with givenSessionID