Neovim, my favourite editor!
Some hotkey to operate vim
Use vim-plug in neovim
The neovim config file is in
~/.config/nvim/init.vim
w
we should create two directory~/.config/nvim/autoload
~/.config/nvim/plugged
1 | mkdir -p ~/.config/nvim/autoload ~/.config/nvim/plugged |
1 | # Download vim-plug |
Append new lines in vim config file(Neovim
is in ~/.config/nvim/init.vim
)
1 | call plug#begin('~/.config/nvim/plugged') |
Then,reload the config file,change vim to the command mode, tap these
1 | :PlugInstall |
And you have completely installed the vim-plug
Single option to edit
- Command
a
could get into the insert mode after the current character. - Command
Shift
+a
could get into the insert mode at the last of the current line. - The command
i
could get into the insert mode before the current character. - Command
Shift
+i
could get into the insert mode at the begin of the current line. - Command
o
could get into the insert mode at the next line beginning. - Command
Shift
+o
could get into the insert mode at the previous line beginning. - Command
u
could undo the previous actoin. - We can use
"
to comment the vimrc - In the command mode,keyword
%
means the current file itself. - We can use
$
to move the cursor to the end of a line
1 | <operation> <motion> # The command format is Kind of this mode |
d
command is the delete key
When we use d
+Right
+3
,means delete 3 letters on the right side
- Tap
: set spell
,the incorrect syntax will be found.
choose a incorrect word,tapz=
,then,you will find lots of words advice from vim.
- When you jump to another place,you want to go back to the previous code block,you could use
Ctrl
+ o
,also,you could use Ctrl
+ i
to go back again
- When your cursor is on a filepath,tap
gf
to open it within the current window(then you can also tapCtrl
+o
to go back to the previous file)
⭐️Tip one
If you are editing a/etc
file but don’t have the root privilege,and exit will lose the contents forever.
Then you can tap these commands to save your data
1 : w !sudo tee %then you input some enter will be right
Attention: this command is perfect to run in vim,but not neovim⭐️Tip two
we can append a rule in vimrc,like
1 map \<LEADER>\<LEADER> \<Esc>/<++>\<CR>: nohlsearch\<CR>c4lFrom now on,if we write
<++>
in a file,then we tap double spaces we can change new characters replacing the previous one.⭐️Tip three
a combo with figlet
- install the figlet(
brew install figlet
)- tap these commands to insert a figlet words into the file
1 : r !figlet NICEthen we’ll get this one
⭐️Tip four
print the vim file into the HTML format (will open another vim window)
1 %TOhtmlwhen we tap
wq
in the new genarete file,we can open it with the browser
Edit the vimrc
Use map to custom the keybind
Custom setting
1 | # increase the line number |
map
1 | # tap j,means k |
Special keys
1 | notation meaning equivalent decimal value(s) |
Split your vim workspace
Edit the vim config file~/.config/nvim/init.vim
,then append these configurations
1 | # set a mapleader key |
open another file,we can tap: e ~/try/2.txt
to open another file in your vim
Vim Tab Manager
1 | # create a new tab |
Recoding a macro
- Tap
q
,then Tap a Character you want,such asa
Vim will recode a macro marked with a
- Do anything you want.
- Tap
@
+a
will execute the macro
VISUAL LINE
V-LINE mode
Tap the Shift
+v
could get into the V-LINE mode,and we could batch operate these lines.
then,Tap the :
,we could input the batch operate the lines
1 | # Append 2022- to the beginning of these lines |
V-BLOCK mode
Tap the Ctrl
+v
could get into the V-BLOCK mode,and we could batch operate the selected blocks
then,Tap the :
,we could input the batch operate the lines
1 | # Append 2022- to the beginning of these selected blocks,and Tap the Enter key will see the changing |
Vim-Plugs
preservim/nerdcommenter
Use
space(My <LEADER>)
+cc
to add a commentUser
space(My <LEADER>)
+cu
to cancel a comment
tpope/vim-surround
Use
cs"'
can change the word surrounding become to'
from"
Use
cs"<q>
can change the word surrounding become to<q>
from"
Use
ds"
can cancel the word surrounding
tmhedberg/SimpylFold
Use
zo
to open a folded code blockUse
zc
to close a fold
CoC
- Use
space
+r
+n
to rename a variable
mbbill/undotree
Add a configuration to the init.vim
1 | nnoremap <C-h> :UndotreeToggle<CR> |
- Use
Ctrl
+H
to open the undotree toggle
FzF
Add a configuration to the init.vim
1 | nnoremap <Leader>C :Colors<CR> |
- Use
\<LEADER>
+f
to search files
NerdTree
Add a configuration to the init.vim
1 | nnoremap <C-f> :NERDTreeFind<CR> |
Use Ctrl
+ f
to open the NerdTree
mhinz/vim-startify
Just install the pluggin is well
mg979/vim-visual-multi
- When you cursor a word,tap
Ctrl
+n
to select a word and get into the visual-multi mode
Then you can change them batching
Neovim, my favourite editor!