- Published on
Vim KeyShort
Background
In the past, we used Vim primarily for basic text editing, without taking advantage of its powerful features. To boost our productivity, we now aim to learn advanced Vim techniques and embrace a more mouse-less workflow.
Since we use the Vim extension in VSCode, we follow the roadmap to learn and utilize Vim commands within VSCode.
Some Useful Commands
here we only list some useful commands, for more details please refer to the Vim Cheat Sheet
Motion: How to Move
f
&t
- Find and Jump.;
&,
- Repeat and Undo forf
andt
.
Text Object Move
(
&)
- Move to the beginning and end of a sentence.{
&}
- Move to the beginning and end of a paragraph.
Position Jump
ctrl + o
- Jump to the previous position.ctrl + i
- Jump to the next position.
Scrolling
zz
- Center the current line in the window.zt
- Move the current line to the top of the window.zb
- Move the current line to the bottom of the window.
Search
/
?
- Search forward or backward, then pressn
to repeat the search.*
#
- Search for the word under the cursor.
Editor Text
p
y
- Paste and Yank.r
R
- Replace and Replace All.c{motion}
- Change text within a motion.>>
<<
- Indent and Unindent..
- Repeat last action.q{a-z}
- Record a macro.@{a-z}
- Execute a macro.
Ctrl Commands
ctrl + d
/ctrl + u
- Scroll down/up half a page.ctrl + o
/ctrl + i
- Jump to previous/next position in jump list.ctrl + r
- Redo.
Note: On Windows,
ctrl + c
andctrl + v
are commonly used for copy and paste in most applications. In Vim,ctrl + c
is similar toEsc
(cancel/interrupt), andctrl + v
enters Visual Block mode. To avoid confusion on the keyboard, here we to close thectrl+ANY
commands by the"vim.useCtrlKeys": false
setting insettings.json
.