** 2025-11-12 03:05:43 +0000 UTC ** about 1616 words ** 8 min
Even with years of vim usage, you can still learn a new hidden feature every day!
Ok, I might have exaggerated, but you know what I mean if you use Vim.
If you participate to the Vimovember, don’t hesitate to send me a link with your answers.
🌱 - Beginners ⚙️ - Intermediate 🧠 - Advanced 💬 - Reflect on the challenge
01 Modes 🌱
Modes can be awkward for many users.
The modes are: normal, visual, insert, command, and replace.
One of the thing I use really often, and is unknown to many is to use in Insert mode, <C-o>.
It allows you to do a normal command, and get back directly into the insert mode.
Imagine a word is missing in your sentence. You wa…
** 2025-11-12 03:05:43 +0000 UTC ** about 1616 words ** 8 min
Even with years of vim usage, you can still learn a new hidden feature every day!
Ok, I might have exaggerated, but you know what I mean if you use Vim.
If you participate to the Vimovember, don’t hesitate to send me a link with your answers.
🌱 - Beginners ⚙️ - Intermediate 🧠 - Advanced 💬 - Reflect on the challenge
01 Modes 🌱
Modes can be awkward for many users.
The modes are: normal, visual, insert, command, and replace.
One of the thing I use really often, and is unknown to many is to use in Insert mode, <C-o>.
It allows you to do a normal command, and get back directly into the insert mode.
Imagine a word is missing in your sentence. You want to move your cursor five words before, you can do:
<C-o> + 5b (5 words back) and you’re back in insert mode directly.
02 Move 🌱
Vim offers many effective ways to move around in your files.
Beyond the common ones: 0, $, gg, G, there are also some I use quite often:
`. That’s backstick and the dot. It will move to the last exact place where you edited your files.
Or '. The quote and the dot does the same but it goes at the start of the last edited line.
Of course, I love also { and } for paragraphs, and many others!
03 Delete 🌱
While we have the common dd, x or d{motion} like dap to delete a paragraph or daw to delete a word, there are less known ones.
When you do a ’d’ like ‘dap’ to delete a paragraph, Vim copies it in the yank register, overwriting what you have copied before.
To avoid that, use the “black hole register”:
"_d{motion}
"_dd will delete the line without storing it.
Some other tips:
:g/foo/d " delete lines containing foo
:v/foo/d " delete lines NOT containing foo
:g/^$/d " delete all empty lines
da( " delete a pair of parentheses and content
di' " delete inside quotes. It works with double quotes too
da{ " delete a block with braces
d2ap " delete two paragraphs
dtX " delete until character `X`
dfX " delete through character `X`
dT/ dF " same but backward
:1,.d " delete from top to current line
:%d " delete the entire file
:/foo/,/bar/d " delete from the first match of foo to first match of bar
d3w " delete three words
dG " delete to end of file
dgg " delete to beginning of file
There are so many great ways to edit your files.
04 Numbers 🌱
Everybody knows <C-a> to increment a number, and <C-x> to decrement a number. Just put the cursor on the line of a number and hit, the keys! Ma - gic !
Another thing that you may want to try:
- open a file
- type:
0
0
0
0
0
0
then <C-v> or V to select the lines “visually” hit the keys: g <C-a> Enjoy the result:
0
1
2
3
4
5
It works also if you do with two or more zeros (00, 000, etc)
Generate a sequence of numbers from the command mode:
:put =range(10, 50, 10)
will generate:
10
20
30
40
50
:put =range(100, 0, -25)
100
75
50
25
0
The range is (start, end, increment/decrement)
05 Undo 🌱
Even if you don’t have a DeLorean to travel back in time, with Vim you can use two commands to do it :
:earlier 10m " will display the current file how it was 10 minutes ago.
:later 5m " will revert changes that were written 5 minutes after going back
" 10 minutes
Other tips:
3u → undo last 3 changes.
<C-r>3 → redo last 3 undone changes.
Personally, I use this plugin: https://github.com/mbbill/undotree.
Just go, and check it out!
06 Visual 🌱
Visual selections aren’t often used, but <C-v> to select a column block, and v are great if used correctly.
Here are some tips:
- Use
<C-v> } I# <Esc>
Replace in visual mode
- select lines or characters with
vor<C-v> - type
r@to replace all of them with the @ character.
Change case of selected text
- gU → uppercase
- gu → lowercase
- ~ → toggle case
Select your last visual region
- use
gv
Substitute only in a selected region
- Use
:'<,'>s/dog/cat/g
Bonus tip
When selecting with <C-v>$, it extends to the end of each line individually.
<C-v> 5j $
A, <Esc>
Appends , at the end of each of 6 lines, even if they’re different lengths.
07 Search 🌱
Vim offers many built-in features for searches:
*and#: searches for the word under the cursor forward / backward
While the above matches only the whole word, there is another option to find the word inside bigger words. Use g:
*and#match car onlyg*andg#match car, cars, carpet(s), carapace, etc…
Doing something on your last change with gn or gN
dgn- delete next matchcgn- change next matchygN- copy previous match
After an operation, just hit . to repeat the change on the next match.
Counting occurrences of a word
- Use
:s/word//gnit will print something likex matches on x lines
Then, you can use n/N to search the next/previous results it found. Of course, it’s doable on a visual selection too.
Search and replace
- Use
:%s/foo/bar/gc.gfor global, meaning the entire file, andcto confirm.
Search your history
In Normal mode, if you want to search your history, hit q/ and it will open a new buffer with all your history searches. Pretty nice way to look into your history.
Search through your files
- Use
:vimgrep pattern **/*md - Then open a new buffer with a list of all files: :copen
- Navigate through the files using
:cnextand:cprev
If interested in more things, like how I use Telescope, and other plugins, you can check: https://lazybea.rs/tags/vim/
08 Substitute 🌱
In Day 7, we showed the use of :%s/foo/bar/ to replace foo with bar.
But, did you know that you can use :%s//blah/ to use the last search in a substitution using the // shortcut.
Another great tip for substitutions is cgn. It will search your last search, and put you in a change/interactive mode.
Hit , and . and it will go to the next one.
You don’t have to use only %, you can substitute:
- on visually selected lines:
:'<,'>s/foo/bar/g - by line numbers:
:10,20s/foo/bar/g - relative to the cursor:
:.,+5s/foo/bar/g(current line to +5) You can use -5 to search 5 lines above your cursor too. - with
:global. For example, replace only on line matching a pattern::g/pattern/ s/foo/bar/
09 Repeat 🌱
Most Vim users know:
. -> repeats your last insert
@. -> repeats your last macro
But many don’t know how to repeat your last Ex command:
@: -> repeats your last Ex command
Another one I like is to use @@ to repeat the last executed macro you created with q.
So if you ran @q, you can now type:
@@to repeat it once10@@to repeat it ten times
Bonus tip
Did you know you can type an Ex command to repeat something: :normal .
:3,10normal .
> repeats your last change on every line from 3 to 10.
Combine this with macros or registers, and you have automation magic without writing loops.
10 Insert tricks 🌱
-
Press
<C-o>to run one Normal mode command, then return to insert mode. -
<C-r> {register}to insert register content.<C-r>0“ Insert last yanked text`. -
<C-r> =strftime('%c')will insert this date Mon 10 Nov 2025 17:30:49 GMT<C-r> =512+512will insert 1024. -
<C-t>/<C-d>– Increase/Decrease line indent while in Insert mode. -
<C-k>insert a Unicode or special character using:digraphs: -
<C-k>Eu-> € -
<C-k>$$-> £ -
Filename completion in the current directory with
<C-x><C-f> -
<C-x><C-l>Whole line completion, Vim searches the buffer for lines that start with what you’ve typed and offers completions.
I have an insert that I use in scripts like this: nvim '+norm! ifzek ' +startinsert $NOTE. This opens the $NOTE file, inserts a snippet called fzek, and starts Insert mode. All I have to do is press the tab key to have my front matter ready for the new note.
11 Registers ⚙️
I already wrote about some registers previously:
<C-r>=3+3-> inserts 6- the blackhole registor
_"to avoid overwriting the default register.
One I use often is <C-r>. that’s not a true register but acts like one. You can check it with :help i_CTRL-R_.. It’s actually useful to repeat snippets without using macros.
Read only registers
-
:,/,%registers: -
:the last Ex command -
/the last search pattern -
%the current filename
You can paste them:
- Insert mode:
<C-r>%inserts current filename - Insert mode:
<C-r>/inserts last search pattern - Command mode:
:!grep foo <C-r>%runs command on current file
Inspect Registers
There is a way to see all the registers, using :reg or :registers. It’s not a thing I use often, but it’s nice to know it exists.
You can check specific registers using :reg a b " for example. You might not know that you use the command :reg / to view the last search or :reg . to view the last insert.
12 Macros ⚙️
13 Marks ⚙️
14 Split ⚙️
15 Buffers ⚙️
16 Tabs ⚙️
17 Fold ⚙️
18 Config ⚙️
19 Plugins ⚙️
20 Replace in Files ⚙️
21 Autocmd 🧠
22 Mappings 🧠
23 Quickfix 🧠
24 Shell 🧠
25 Block Mode 🧠
26 Tags 🧠
27 Grep 🧠
28 Sessions 🧠
29 Custom Function 🧠
30 Reflect 💬
