Vim keystrokes cheatsheet
The time has come for me to list few of the commands and keystrokes that I use (and the ones that I don't but would like to start) in Vim.
I am actually running a Vim plugin for Visual Studio Code (this and the previous blogs are actually written with this plugin ON) at this very moment.
Bear 🐻 in mind: this blog is aboout keystrokes only, it is not about plugins or configuration I use - I shall cover that one day.
Things I know by heart
h,j,k,lfor slow but precise character-wise movementw,bfor faster forward (and, correspondingly) backward word-by-word movement$and^to go to the last and first word character of the lineggandGto go to the beginning and the end of the fileO(capitalo) to create a blank line and go to INSERT mode above and below (lower-caseo) the cursorf,FandtandTfor single character lookup within the current line/and?to search forwards and backwardsc(followed by the object) to change the object; this expands to the following few commands:cwto change the current word under cursorcitto change the text within the current XML tagca'to change the text surrounded by single quoteci<to change the text surrounded with<and>ci{symbol}to change the text surrounded by symbol, which could be',",`; you can also useb(for block of text, surrounded by braces,B{for block of text surrounded by curly braces orpfor paragraph, all instead of symbol
vto enter the VISUAL mode, followed by the command:v{select}cimmediately change the selectionv{select}dcut the selected text
yandpcopy and paste the selected text (lower-caseppastes above the current line, capital-casePpastes below; capital-caseYcopies the entire line, so the duplicate line command in Vim isY, P){number}{command}repeat the command number times.(the period or dot symbol) repeats the last commandxto remove the character under cursorr{char}to replace the character under cursor with charAto go to the end of the line and enter INSERT mode ("append")uandCtrl+rto undo and redo actions>and<adds or removes the indentation
Things that I am still getting used to
{number}{motion}instead ofh,j,k,lainstead ofito enter INSERT mode after the cursor (as opposed toiwhich enters INSERT mode before the cursor)H,MandLto go to the top, middle and the bottom of the screen (High, Mid and Low)*and#to search for the word under cursor forwards and backwards{count}/{query}⏎to go to the count-th occurrence of query; it is same as searching with/and then hittingncount timesgdnavigates to a definition of an entity under the cursorgfnavigates to the path under cursor%moves the cursor to the matching brace, bracket or curly braceg~toggle the case=format the selectiongUmakes the selection uppercase