go to different window, require plugin: tmux-navigator
ys+w+quote
n
add quote to a word, require plugin: vim-surround
ds+quote
n
delete quote of a word, require plugin: vim-surround
cs+quote1 quote2
n
change quote1 to quote 2 of a word, require plugin:
vim-surround
y w
n
copy a word, require plugin: replace-with register
g rw
n
paste and change a word: replace-with register
gcc, gc9j
n
comment a line or comment 9 lines, require plugin: Comment
e
n
open explore, requrie plugin: nvim-tree
a
n
in expoore, type a to add a file
ff
n
find file in current director, require plugin: telescope
fs
n
find text in current director, require plugin: telescope
fc
n
find current text under the cursor in current director, require
plugin: telescope
fh
n
show help information
k,j
n
in telescope output, go to up and down results
ll
n
VimTex compile
lk
n
VimTex compile stop
lv
n
VimTex forward search
lt
n
VimTex toc
le
n
VimTex find error
lc
n
VimTex clear aux file
nvim-surround plugin usage
ys{motion}{char}, ds{char}, and
cs{target}{replacement}
target defines: iw for current word char defines:
char
defines
b
()
B
{}
r
[]
In visual mode, after you choose some text, you press
Shift s, then you can type the surround stuff which you
want to add.
eg: if you choose xx, then you press Shift s
followed by yy then xx will turn in to
yy xx yy
orderlist plugin usage
inverse: leader+x
reorder: <leader>+r
3 steps to add a plugin in neovim
add a plugin in the plugin-setup.lua
if the plugin need config, create a corresponding config file in
plugin folder. import the config file in the init.lua
file.
if need any shortcut for that plugin, add the corresponding keybinds
in the keymaps.lua file
For LSP, you can go to mason
website to check all the available lsp server.
LSP shortcuts:
shortcut
function
i
install
X
uninstall
u
upgrade
neovim shortcut
Space is set to be the header key, we
can just press Space to see the information table of our Neovim
config.
shortcut
usage
gl
show error description
gD
go to function declaration
gd
go to function definition
gI
go to implementation
gr
find all the referrences
K
show info in popup window
Space+f
search document by name
Space+F
search text by name
Space+lj
go next
Space+lk
go prev
Space+lf
format document
Space+li
LspInfo
Space+lI
LspInstallInfo
Space+la
code action
Space+e
open explore
Shift+l
choose file on the right
Shift+h
choose file on the left
Ctrl+\
popup terminal
jk
press jk fast to back to normal mode from enter mode
< or >
in visual mode, move code segment left or right
Shift+j,k
in visual mode, move code segment up or down
gc
in visual mode, comment all codes
vim shortcut
shortcut
usage
vsp
vertical spite window
sp
horizontal splite window
Ctrl+w, <h,j,k,l>
change between the windows
Ctrl, <h,j,k,l>
change between the windows <- using keymap in neovim
f,F target
find the target, use ; to find next target
Ctrl+o
go to the previous location
Ctrl+i
go to the next location
set colorscheme in vim:
add the colorscheme in plugin.lua file
type colorscheme darkblue in vim command windows to use
that colorscheme.
add vim.cmd "colorscheme darkblue in init.lua to use
that colorscheme.
"ap: paste content in register a "ayaw: copy current word into register a
搜索替换
全文替换:%s/source/goal/g
替换一行所有匹配项:s/source/goal/g, the difference is
that we change %s into s
替换某几行所有匹配项:shift+v choose some lines,
s/source/goal/g
替换当前行及下面 n
行所有匹配项:,+ns/source/goal/g
删除unicode <200b>:
%s/\%u200b//g
install plugin in neovim
plugin config file is plugin.lua
all installed plugins is under
~/.local/share/nvim/
add new LSP server in neovim
use LspInstall to install the corresponding server for
your target file. The server will be installed by Packer to path
.local/share/nvim/site/pack/packer/start/
add a config file under lua/user/lsp/settings for the
language server. This website
contains all the template config file for almost all languages.
turn on that language server in file mason.lua
For example, if I want to install LSP server for LaTex, I do the
following things:
install language for LaTex, it's texlab.
create a config file texlab.lua under
lua/user/lsp/settings, and type in the corresponding config
codes.
I add texlab in the local_servers field in
mason.lua.
convert init.vim to init.lua
basic vim config
1 2 3 4 5 6 7
-- vimscript set number set tabstop=4 set shiftwidth=4 set softtabstop=0 set expandtab set noswapfile
all: $(cObjects) # default make target gcc $(cObjects) -o main
# compile .o file for each .c file $(cObjects): %.o: %.c # static pattern->targets: target-pattern: dependency-pattern $(CC) -c $(CFLAGS) $< -o $@# `$<` means dependency, `$@` means target
.PHONY: clean all
clean: @# echo "clean all temp files" # with @, the command will not appear when using `make` @echo"all file paths: " $(cFilesPath) @echo"all c files: " $(cFiles) @echo"all object files: " $(cObjects) @$(MAKE) -C src # equal to `cd src && $(MAKE) @# -rm *.o main