Article^ Parent
Vim 笔记
Date: | 2016-08-10 00:00:00 |
Description: | Vim 使用笔记。 |
Keywords: | Vim, 使用 |
Category: | engineering_technology/computer/software/tool |
Tag: | vim |
Link: | https://www.diewuxi.com/blog/article/100.html |
Changelog
* 2024-06-12
* Add: Add insert register content to command line mode.
* 2022-05-28
* Add: Replace.
* 2021-06-02
* Add: Window move.
* 2021-05-29
* Modify: Use normal markdown code format.
* Add: Comment for command.
* Add: Window operation command.
* 2018-09-21
* Add: Mksession.
* 2016-08-10
* Done
Mode
Insert
{number}i Before current character
{number}a After current character
{number}I Before whole line
{number}A After whole line
{number}O Before current line
{number}o After current line
Command
:{command}
View
Save/exit
;write [filename]
:wq
:x
:quit
:quit!
:wq!
Move
{number}k
{number}j
{number}h
{number}l
{number}w Go forward word start
{number}b Go backward to word start
{number}e Go forward word end
{number}ge Go backward word end
{number}G Go to line {number}
G Go to last line
gg Go to first line
Edit
Delete
{number}x
{number}X
{number}d{move}
{number}dd
Quick edit
.
Cut/copy/paste
y{move}
{number}yy
{delete}
p
P
Replace
r
R
~
c{move}
Undo/redo
u
U
ctrl-r
Fomat
Indent
>>
<<
Aliment
:center
:left
:right
Find
/
?
*
#
g*
g#
n
N
Multi file edit
vim {filename1} {filename2} ...
:edit {filename}
:buffers
:bad {filename}
badd {filename]
:n
:N
:file
Visual mode
v
V
ctrl-v
Window
:split / ctrl-w s
:vsplit / ctrl-w v
:quit / ctrl-w q
:close / ctrl-w c
:resize {number} / ctrl-w {number}_ Set window height
:resize -{number} / ctrl-w {number}- Decrease window height
:resize +{number} / ctrl-w {number}+ Increase window height
:vertical resize {number} / ctrl-w {number}| Set window width
:vertical resize -{number} / ctrl-w {number}< Decrease window width
:vertical resize +{number} / ctrl-w {number}> Increase window width
ctrl-w = Equal window height/width
ctrl-w {move}
ctrl-w w Move cursor to below/right window
ctrl-w W Move cursor to above/left window
ctrl-w t Move cursor to top-left window
ctrl-w b Move cursor to bottom-right window
ctrl-w r Roate window downward/rightward
ctrl-w R Roate window upward/leftward
ctrl-w x Exchange current window with next one
ctrl-w K Move window very top
ctrl-w J Move window very bottom
ctrl-w H Move window very left
ctrl-w L Move window very right
ctrl-w T New tab
Session
:mksession [session_file]
:source {session_file}
# vim -S .vim/session/session1.vim
Replace
Character to newline:
s/{CHAR}/\r/g
Registers
- Insert register content to command line
Press <C-r>
, then press <register_letter>
.
For example, yank a word in visual mode with y
, then in command line, insert it by:
<C-r>"
Last modified: 2022-05-28
Comments [0]
There is no comments now.