Previous Post | Top | *** |
TOC
Frequently used (n)vim actions
Here are my frequently used vim tricks under my LazyVim settings.
-
change VIM operation mode
<esc>
or quickjk
– INSERT to NORMALa
/A
– NORMAL to INSERT (after cursor/line)i
/I
– NORMAL to INSERT (before cursor/line)o
/O
– NORMAL to INSERT with a open line (after/before)R
– NORMAL to REPLACE (on cursor)r
is for single char and not so useful (?may remap toR
?)
v
/V
/<C-v>
– NORMAL to VISUAL / V-LINE / V-BLOCK
For NORMAL mode:
-
cursor motions
h
/j
/k
/l
– cursor movej
shape points to downward.k
shape points to upward.
<c-h>
/<c-j>
/<c-k>
/<c-l>
– window jumpH
/L
– tabline jump (remapped)J
– join line,K
– LSP
<C-left>
/<c-down>
/<c-up>
/<c-right>
– window resizew
b
andW
B
– next(forward)/previous(backward) start of worde
ge
andE
gE
– next/previous end of wordg
and]
and[
+ α – move with which-key selectiongg
– move to the top of fileG
– move to the bottom of file0
– move to the first column of the line^
– move to the first non-white space char of the line$
– move to the last column of the line
-
searches
f
/F
/t
/T
+{char}
fβi
==tβa
but I tend to use prior- repeat with
,
and;
, prefix with repeats
/
/?
+{string}
– repeat withn
andN
*
/#
– repeat withn
andN
m
+ β – mark as β'
+ β – jump to β (You may use`` (backtick) instead of
’`)
-
screen motions and foldings
<c-b>
/<c-u>
/<c-d>
/<c-f>
– screen jump (up, up/2, down/2, down)zt
– position cursor line at the top of screenzz
– position cursor line at the center of screenzb
– position cursor line at the bottom of screenz
+ α – fold operations with which-key selection
-
actions
u
– Undo<C-r>
– Redo.
– Repeat
-
actions with motion or text objects
c
/d
/y
+{motion}
ciw
change in a word (inside)cib
change in a whole balanced(...)
[...]
{...}
cit
change in a whole balanced<tag>...</tag>
ci"
change in a whole balanced"..."
c5e
change next 5 words from cursor
v
+ cursor moves +c
/d
/y
– actions with visual selection
-
actions cut and paste like
p
– paste (after)P
– paste (before)dd
– delete a whole lineD
– delete cursor to the end of linecc
– delete a whole line and insertC
– delete cursor to the end of line and insertJ
– join with the next line
-
actions with MACRO
q
+ β – record MACRO as βq
– End-Recording MACRO@
+ β – Play Recorded MACROQ
– Play the last Recorded MACRO<C-r>
+ α – paste with selection + α
-
global substitutions
:%s/pattern/subst/gc
– all lines in the file:cdo s/pattern/subst/gc
– all quickfix lines
-
reformat (
V-LINE
mode)gq
– reformat LSPgw
– reformat VIM=
– re-indent>
– increase indent<
– reduce indent
-
Tag jumps (
:help
)<C-]>
– jump to link-destination<C-t>
– jump back to link-source<C-i>
/<C-o>
: jump next / previous link-destination
-
quickfix tricks
:vim /pattern/ %
– search within a file:gr 'pattern' ##
– search within all open files:cdo {cmd}
and:cfdo {cmd}
– execute{cmd}
for all quickfix items:cex script.sh
[q
and]q
mapped to:cprev
and:cnext
:packadd cfilter
and use:Cfilter[!]
– maybe not as useful over<leader>xs
with<tab>
.:colder
and:cnewer
- Quickfix FzfLua UI
<leader>xs
(or<leader>st
) to access quickfix list<Tab>
/<S-Tab>
is to mark list item<c-q>
/<m-q>
is to down-select to marked or unmarked items
<leader>xh
is to access quickfix stack to access older quickfix list
:h
– help:on
– only:wall
– write all buffers:qa
– quit all buffers if already saved
Here, I used:
- “α” for a which-key prompted key input.
- “β” for a single character input.
For INSERT mode:
<c-c>
– Quit insert mode (It seems this is useful when resize cause screen freeze.)<c-u>
– Erase line before cursor<c-v>
– Input non-ascii using octal etc.<c-w>
– Erase a word before cursor<c-r>
– Insert register (with which-key help)
I realize I don’t use nor remember other esoteric keymps (especially ones in INSERT mode.).
Benefit of LazyVim over plain Nvim
Linters and formaters assisted by easy install via mason are the biggest benefit of using LazyVim.
LazyVim specific tricks
Now :message
is shown in pop-up. Use <leader>snh
or <leader>m
to check.
Give up for now
- Stay out of “Lication list” and stick to “Quickfix List”
- Stay out of DAP
- Keep tab and navigate with
H
/L
and give up using their native functions.
Previous Post | Top | *** |