Vim:
https://vimdoc.sourceforge.net/htmldoc
Vscode vim
https://www.bilibili.com/video/BV1z541177Jy?p=6&vd_source=1cfe4f7c9bf04285f79b848e60f55aea
After installing the plug-in, copy the default configuration
Patterns
normal to insert
Insert to normal
jj has to do with the settings
Normal to visual
normal to command mode
Cursor movement
It's all normal mode
Normal Move
Word moves
Row moves
- '|' moves to the first character at the beginning of the line.
Other moves
- 'Ctrl-E' screen scrolls down one line.
- 'Ctrl-Y' screen scrolls up a line.
Find and Replace
https://harttle.land/2016/08/08/vim-search-in-file.html
People always ask me if I can find it in Vim, and of course I can! And it's super strong! This article will take a closer look at the settings and usage methods of Vim. These include Find & Replace, Find Cursor Words, Highlight Foreground/Background Color, Toggle Highlight Status, Case Sensitive Lookup, and more.Find
Press / in normal mode to enter find mode, enter the string you want to find and press enter. Vim jumps to the first match. Press N to find the next one, and N to find the previous one.
Vim lookups support regular expressions, such as /vim$ matching "vim" at the end of a line. You need to find special characters that need to be escaped, e.g. /vim\$ matches "vim$".
Other Find Modes- '?' (Shift + '/') to look up.
- 'Q/' to view the search history, select one item and press enter to search again.
- 'q?' to view the lookup history.
Case-sensitive lookups
Add '\c' to the lookup pattern for case-insensitive lookups and '\c' for case-sensitive lookups. For example:
/foo\c
All strings such as '''foo'', ''FOO'', ''Foo'' will be found.
Case-sensitive configuration
Vim defaults to case-sensitive lookups, which we often configure to be case-insensitive:
Set IgnoreCase by default for case-insensitive lookup If there is an uppercase letter, switch to a case-sensitive lookup Set Smartcase
Paste the above settings into your '~/.vimrc' and reopen Vim to take effect.
Find the current word
Press '*' in normal mode to find the word where the cursor is located, and require white space characters or punctuation marks before and after each occurrence. For example, if it is currently 'foo', it can match the 'foo' in 'foo bar', but not the 'foo' in 'foobar'. This is useful when looking up function names, variable names.
Press 'g*' to find the character sequence of the word where the cursor is located, and there is no requirement for characters before and after each occurrence. That is, both 'foo bar' and 'foo' in 'foobar' can be matched.
Other settings
':set incsearch' can search while pressing the key, press enter to move the cursor to the matching word; Press Esc to cancel the search.
':set wrapscan' is used to set whether to start the search again from the header of the file after reaching the end of the file.
Find & Replace
The '😒' (substitute) command is used to find and replace strings. The syntax is as follows:
:{Scope}s/{target}/{Replace}/{Replace}/{Replace}
For example, ':%s/foo/bar/g' will look for 'foo' in the global scope ('%') and replace it with 'bar', and all occurrences will be replaced with ('g').
Scope
The scope of action is divided into current line, full text, selection, and so on.Current line:
:s/foo/bar/g
Full text:
:%s/foo/bar/g
Select the area, enter ':' after selecting the area in Visual mode, Vim will autocomplete to ':'<, '>'.
:'<,'>s/foo/bar/g
Lines 2-11:
:5,12s/foo/bar/g
The current line '.' and the next two lines '+2':
:.,+2s/foo/bar/g
Checked (visual mode)
V:
Ctrl+V block selection,
Shift+V row selection
Press Shift + < again to move the code to the left, and Shift + > to move the code to the right
Multi-line editing (Ctrl+V) block selection
https://www.jianshu.com/p/50d5b6cfd73b
operator
The first letter is the action: C (Modify) D (Delete) Y (Copy) V is checkedThe second is the range i (inside) a (contains the boundary) t (from where to where)
This is followed by the identifier of the boundary ( [
Then you will enter the insertion
normal mode
Press d to move the cursor to delete
dd to delete one line
cc cut a row
yy to copy a line
U is undone,
P paste
ctrl+r redo
```yaml di[ removes all characters from a pair of []. di( removes all characters in a pair (). di< removes all characters from a pair of <> di{ removes all characters in a pair of {} dit removes all characters inside a pair of HTML/XML tags di" di' di removes all characters in a pair of quotation mark characters (" or ' or ). ```Replace mode
http://yyq123.github.io/learn-vim/learn-vi-44-ReplaceMode.html
Surround mode
[VIM Study Notes: Surround] (http://yyq123.github.io/learn-vim/learn-vim-plugin-surround.html)
Case conversion
easymode
The leader is equipped with a space
Change sourround
## Multiple cursorsctrl+d
Command Line Mode [:Enter]
n Skip to the first row
Find Patterns
https://harttle.land/2016/08/08/vim-search-in-file.html
Current line:
:s/foo/bar/g
full text
:%s/foo/bar/g
Select the area, enter ':' after selecting the area in Visual mode, Vim will autocomplete to ':'<, '>'.
:'<,'>s/foo/bar/g
Lines 2-11:``` :5,12s/foo/bar/g
The current line '.' and the next two lines '+2':
:.,+2s/foo/bar/g
### Replace the marker
The 'g' at the end of the command above is one of the substitution flags, representing the global 'global' substitution (i.e., all occurrences of the substitution target). There are a lot of other useful replacement flags:
The empty replacement flag indicates that only the first occurrence of the target is replaced from the cursor position:
:%s/foo/bar
'i' for case-insensitive lookups, and 'i' for case-sensitive:
:%s/foo/bar/i
Equivalent to \c (insensitive) or \c (sensitive) in the pattern
:%s/foo\c/bar
'c' indicates that confirmation is required, e.g. global lookup '''foo'' is replaced with '''bar'' and confirmation:
:%s/foo/bar/gc
## Macros
1. Position the cursor on the first line;
2. Enter qa in normal mode (of course, you can also enter qb, qc, etc, where a, b, c refers to the register name, vim will put the recorded macro in this register)
3. Under normal circumstances, the command line of vim will display the words "start recording", at this time, position the cursor to the first character (press 0 or |), then press x to delete, press j to jump to the next line;
4.Enter Q in normal mode to end macro recording.
Then 99@a use the macro 99 times
## RegistersView all registers:
```json
:reg command
Use a register:
<ctrl>r plus the name of the register
Special Registers:
. | The last executed command |
| The path to the current file |
| most recent command executed |
| Replace the name of the file, you can think of it as the most recently edited file |
Miscellaneous
Relative line number
Displays the corresponding line number for The number plus J and K can correspond to jumps
"editor.lineNumbers": "relative",
Tab toggle
Use 'gt' to switch to the next tab, 'gT' to switch to the previous tab, and 'n+gt' to go to the n' tab. Of course, you can use the VS Code shortcut 'Alt+n' to switch to the 'n' tab.
Jump definition
Jump definition ctrl+[
(Rewind & Jump)
Jump out of Ctrl+OJump into Ctrl+I
Jump Definition gd
Show Definition tip gh
Toggle tab gt tab g2ts
Panel toggle
Switch to the sidebar cmd+0
Ctrl+~ to open the terminal
ctrl+P to open the command line panel
Ctrl+r to view the list of functions
Cursor movement
Move the cursor to zz in the middle of the screen
Move the cursor to zt at the top of the screen
Move the cursor to the bottom of the screen, zb
Other redirects
https://www.jianshu.com/p/cbfa86c8d8a5
https://vim.fandom.com/wiki/Moving_to_matching_braces
https://vimdoc.sourceforge.net/htmldoc/motion.html#%
Select an entire function
Ctrl+V, at the beginning of the function, enter %
Copy and paste a piece of function
V%y
%pe
[[ : The beginning of the module.]
]]: The end of the module[{:Previous { prefix.]
]}: Next} end
[m: Previous function.]
m: the next function
## Code commentsCode Comment VSC uses something like vim-commentary. How to Use:
- 'gc' - turns annotations on or off. Enter 'gcc' to turn on or off a line of comments, and 'gc2j' to turn on or off two lines of comments.
- 'gC' - Block code comment.Enter 'gCi)' comment code in parentheses ().
Other shortcuts
Shift+J joins the two lines
Input method switching
https://github.com/daipeihust/im-select
https://www.zhihu.com/question/303850876
Window
Download imselect.exe
To view the current input method encoding, you need to use gitbash
Get the input method encoding in English
Toggle English
Keymapping
stickup
Selection of code hints
I chose alt+j and alt+kLinux vim
set nu! displays the line number
Some practical usage
Copy a word
yiw copy the word
viw to select the word to be replaced
Copy and paste a piece of function
V%y
%pe
Switch to normal mode
ctrl+[
Cursor movement
Insert:
Operator plus command
Uppercase E, B, and W correspond to the beginning and end of the string, and the string is separated by a space## Code folding
za: Collapse current rowzM: Collapse All CodezR: Expand all codezc: Collapse the currently selected code block
zo: Expand the currently collapsed block of code (expand only one layer) zO: Expand the currently collapsed block of code (all)
Moving up and down after folding does not automatically open the fold
"vim.foldfix": true