Some useful Vim stuff for prose
A lot of Vim tricks are geared toward working with source code, which I don’t do so much anymore. Below are some that are specifically helpful for working with prose.
This list is not remotely exhaustive.
I’m limiting it to stuff regular folks like me might use on a regular basis.
I’m also skipping past the basics like w / W / b / B / etc.
(If you’re new to Vim, try vimtutor in your terminal.)
If you have a favorite tidbit that I should include here, or if I made any mistakes, please email me!
Text objects and editing commands
ciw: change inner word. Cuts the word under your cursor and enters Insert mode so you can start typing a new one.- Or
ciWto include all non-whitespace characters instead of the regular definition of “word.”
- Or
cis: change inner sentence. Like the above but for the whole sentence.das: delete a sentence. Cuts a sentence cleanly, including surrounding punctuation and whitespace.cipanddap: Like the above but for paragraphs.ci"andci': change text inside quotation marks. Super handy.ci(andci[: change text inside parens or brackets. Great for editing Markdown links!ct.: change till period. Cuts from the cursor to the next period and enters Insert mode.- You can use this with any other punctuation:
ct!,ct:, etc.
- You can use this with any other punctuation:
You can read more about these by looking up help for the relevant text object: :help iw, :help as, etc.
Movements
(/): jump backward / forward by sentence.{/}: jump backward / forward by paragraph.[[/]]: jump backward / forward by section (e.g., Markdown heading).- I believe this works out of the box for Markdown in Neovim, but requires some config in vanilla Vim.
Spelling
Note: Spelling needs to be enabled in your config with :set spell or :set spell spelllang=en_us.
[sand]s: navigate to previous / next misspelled word.z=: show a list of suggested spelling fixes.- Or
<C-x><C-s>in Insert mode.
- Or
zg: mark a word as “good” (add it to your personal dictionary).zw: mark a word as incorrect.zug/zuw: undo the above.<C-x><C-k>: (Insert mode) suggest a word completion from the dictionary (requires dictionary to be configured).<C-x><C-t>: (Insert mode) suggest a word completion from the thesaurus (requires thesaurus to be configured; I’ve never used this but am curious about it).
Surround
These require a plugin, but the surround plugins are perhaps the most popular out there. I’m using mini.surround in Neovim.
With a visual selection, for example:
sa_: surround the selection with underscores (Markdown italic).sd_: delete surrounding underscores.2sa*: surround the selection with two asterisks (Markdown bold).
Digraphs
In Insert mode:
<C-k>-M: em dash.<C-k>-N: en dash.
See :digraphs or :help digraph-table for more.
A couple more goodies
.: repeat your last edit. You can get clever with this if you plan ahead.J: join the next line with the current one.qand@: Record and execute macros. I won’t get into macros here. But if you want to apply the same series of commands in multiple places, look into them. You can do everything from some everyday handy stuff to real wizard shit.