当前位置:网站首页>VIM common commands
VIM common commands
2022-07-29 02:54:00 【Tea white 777】
The overview
vim course
function :
(1) Text editor in command line mode .
(2) Automatically identify the programming language according to the file extension . Support code indentation 、 Code highlighting and other functions .
(3) Usage mode :vim filename
If the file already exists , Open it .
If there is no such document , Then open a new file , And named it filename
Pattern :
(1) General command mode
The default mode . Command input mode : Similar to playing games, playing skills , According to different characters , You can perform different operations . Can copy 、 Paste 、 Delete text, etc .
(2) Edit mode
In general command mode, press i, Will enter edit mode .
Press down ESC Will exit edit mode , Return to normal command mode .
(3) Command line mode
In general command mode, press :/? Any of the three letters , Will enter command line mode . The command line is at the bottom .
Can find 、 Replace 、 preservation 、 sign out 、 Configuration editor, etc .
operation :
(1) i: Enter edit mode
(2) ESC: Enter general command mode
(3) h or Left arrow key : Move the cursor one character to the left
(4) j or down arrow : Move the cursor down one character
(5) k or up arrow : Move the cursor up one character
(6) l or Right arrow : Move the cursor one character to the right
(7) n<Space>:n Representation number , Press the number and then the space , The cursor will move this line to the right n Characters
(8) 0 or Function keys [Home]: Move the cursor to the beginning of the line
(9) $ or Function keys [End]: Move the cursor to the end of the line
(10) G: The cursor moves to the last line
(11) :n or nG:n Is the number , Move the cursor to the n That's ok
(12) gg: Move the cursor to the first line , amount to 1G
(13) n<Enter>:n Is the number , Cursor down n That's ok
(14) /word: Look under the cursor for the first value to be word String .
(15) ?word: Look over the cursor and the first value is word String .
(16) n: Repeat the previous find operation
(17) N: Repeat the previous lookup operation in reverse
(18) :n1,n2s/word1/word2/g:n1 And n2 Is the number , In the n1 Line with n2 Look between lines word1 This string , And replace the string with word2
(19) :1,$s/word1/word2/g: The full text of word1 Replace with word2
(20) :1,$s/word1/word2/gc: The full text of word1 Replace with word2, And the user is required to confirm before replacement .
(21) v: Select the text
(22) d: Delete the selected text
(23) dd: Delete current row
(24) y: Copy the selected text
(25) yy: Copy the current row
(26) p: Place the copied data on the next line of the cursor / Paste in the next position
(27) u: revoke
(28) Ctrl + r: Cancel cancellation
(29) More than no. >: Indent the entire selected text to the right once
(30) Less than no. <: Indent the entire selected text to the left once
(31) :w preservation
(32) :w! Force save
(33) :q sign out
(34) :q! Forced exit
(35) :wq Save and exit
(36) :set paste Set to paste mode , Cancel code auto indent
(37) :set nopaste Cancel paste mode , Turn on code auto indent
(38) :set nu According to the line Numbers
(39) :set nonu Hide line numbers
(40) gg=G: Format the full-text code
(41) :noh Turn off search keyword highlighting
(42) Ctrl + q: When vim Dead time , You can cancel the currently executing command
exception handling :
Each time vim When editing a file , It will automatically create one .filename.swp Temporary files for .
If you open a file , Of the document swp file already exist , May be an error . There are two solutions :
(1) Find the program that is opening the file , And exit
(2) Just delete the swp File can
Special Usage
Quickly delete
ggd Line number , Delete the line from the beginning to line number ;
Such as ggdG, Delete full text , among gg It's the beginning ,d Is delete mode ,G It's the end ;
In the same way gg=G, Full text formatting ;
边栏推荐
猜你喜欢
随机推荐
Tesla neural network model hydranet
Self organization is the two-way rush of managers and members
Redis queue realizes second kill
Interpreting AI robots' pet raising and leading fashion trends
外挂---线段树懒标记板子+简单数学推理
工科男生:20岁未满,平凡但不平庸
【OpenCV】使用OpenCV调用手机摄像头
MySQL 操作数据库数据报错:Fatal error encountered during command execution
Weekly recommended short videos: how to make product development more effective?
Notes on the ninth day
This blogger has a comprehensive classification of QT. If you are free, go to study and summarize it and record it.
php 进程通信系列 (一) 命名管道
Cloud development pocket toolbox wechat applet source code
【luogu P8352】小 N 的独立集(DP套DP)(性质)
QT screen adaptive automatic layout, drag the window to automatically grow larger and smaller (I)
HTB-Blocky
codeforces每日5题(均1500)-第二十五天
数据截断及估计
QT屏幕自适应自动布局,拖动窗口自动变大变小(一)
MongoDB索引 (3)









