General Purpose Cheatsheets
Vim Builtin Package Manager
Commands I forget a lot
:set [setting-name]?to view the current setting value.:echo &rtpto view the runtime path of files that vim checks when running functions.:help rtpfor more.- when you want to reload
.vimrcwithout leaving vim, execute:source ~/.vimrc
Macros
Type qa to start "recording" into register a (I think available registers are a-z and 0-9 and perhaps some special characters as well). This will record an arbitrary sequence of keystrokes, which is the macro itself. Pressing q a second time will end the recording. That macro is now "registered". In order to play back that macro you type @a. I'm not sure how to repeat it via ., but you can repeat it n-many times by typing 3@a for example.
TLDR: qathen arbitrary sequence then q to record macro in register a. Then, @a to play the macro again.
Multiple occurrence
next word
* will select the next word that occurs in that file. n will then move you to the next next word repeatedly. I think you are in some kind of visual mode at this point.
word replacement
Assuming you are in the #next word state, cgn changes the current selected word. . will repeat the change-word action for next next word repeatedly.
Restart lsp server when it crashes in neovim
The quickest solution is :e. This somehow reloads the buffer, which allows for reattachment of LSP. I'm not sure if you have to wait for some form of LSP reboot, since the LSP server is what crashed. But if it does have auto-restart enabled, it should "just work", at least after some time.
Undo and Redo
u in normal mode, or :undo, will undo the lastest vim changes.
ctrl-r in normal mode, or :redo, will redo the undone vim changes.
Tabs
gtnext tabgTprevious tab
Movement commands
(and)move to the next sentence{and}move to the next paragraph
Folding
zatoggle single-fold open or closedzcsingle-fold closezosingle-fold openzMfold everythingzRopen everything
Autoload directory
The autoload directory will reactively load files as you need them, as opposed to some otherwise upfront load that could result in a slow startup. This is especially relevant for larger libraries, or for when you have many libraries. I understand it as lazy loading, essentially. I.e., load the file only when you are literally about to execute a function from within it.
