Make use of plugins! UltiSnips is great and here's a great resource on it.
how to substitute with regex matching
It is useful to substitute up until a certain point.
; to change `split-tiddler-body-and-metadata` quickly...
(define (split-tiddler-body-and-metadata tiddler-filepath slug)# matches from split until finding a space
%s/split\S*def get_noun_gender_from_subsection(subsections: list[Tag]) -> str:
[...]# matches from `get_` until left paren
%s/get_[^)]*/new_name/When doing a match substitution (via something like %s) the matching pattern can be referenced again using \0.
# consider the sentence below
I love apple and vinegar.
# apply the following substitution
:%s/apple/\0 juice
I love apple juice and vinegar.This is nice to match with some code, and add something.
miscellaneous tricks
- # over word to count occurences of a single word!
- gu make lowercase
- gU make uppercase
- :e refreshes the current file
jumps
- CTRL-o/i to jump backward/forward
- g,/; jump to next/previous change
buffers
- CTRL + ^ to change to last active buffer
- CTRL + W s/v split window horizontally or vertically
- CTRL + W n to edit a new file
- CTRL + W ^ to split with the alternate buffer
- <bufferID>CTRL-W ^ split with a given buffer ID
create mappings
:nnoremap - Create mapping for NORMAL mode (non recursive)
:inoremap - Create mapping for INSERT mode (non recursive)
:vnoremap - Create mapping for VISUAL mode (non recursive)
:cnoremap - Create mapping for COMMAND-LINE mode (non recursive)
and some useful mappings
to count characters: vnoremap <leader>q :s/\%V./&/g<CR>
to clear highlighting: nnoremap <leader>h :noh<CR>