vim memo

# First,
apt install vim-gtk3
vim --version
# ensure clipboard feature added,
# then copy to system clipboard,
"+y
# Paste from system clipboard,
<Ctrl+R>+
# content of all registers
:reg
 
:marks
 
:version
:set nocindent
:set noexpandtab
:set paste
 
# record macro to register a, press q if end
qa
# replay macro from register a
@a
 
# open folder containing current file
:Ex
 
# Replace return, space and return chars in a series with one return char, entire file.
:%s/\n\ \n/\r/
 
# In insert mode,
# add char like above the cursor
<Ctrl+Y>
# add char like below the cursor
<Ctrl+E>
 
# till after "
T"
# till before "
t"
 
# exchange current window position with others
<Ctrl+W>r
# or
<Ctrl+W>x
:all
:vertical all
:only

Plugins,

SrcExpl
	https://www.vim.org/scripts/script.php?script_id=2179
	https://github.com/wenlongche/SrcExpl
taglist.vim
	https://www.vim.org/scripts/script.php?script_id=273
	https://github.com/yegappan/taglist

refer to:
https://www.imooc.com/wenda/detail/588162
https://www.cnblogs.com/bwangel23/p/4421957.html
https://blog.csdn.net/Coppa/article/details/108026080

vim+cscope

1
2
apt install vim
apt install cscope

将以下脚本保存为~/.vimrc,注意要用dos2unix转换一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
	if has("cscope")
		set csprg=/usr/bin/cscope
		set csto=0
		set cst
		set nocsverb
		" add any database in current directory
		if filereadable("cscope.out")
		    cs add cscope.out
		" else add database pointed to by environment
		elseif $CSCOPE_DB != ""
		    cs add $CSCOPE_DB
		endif
		set csverb
	endif
 
	nmap <C-[>s :scs find s <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>g :scs find g <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>c :scs find c <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>t :scs find t <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>e :scs find e <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
	nmap <C-[>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
	nmap <C-[>d :scs find d <C-R>=expand("<cword>")<CR><CR>
	nmap <C-[>a :scs find a <C-R>=expand("<cword>")<CR><CR>

每次源码更新时,在源码根目录执行

1
2
3
#find . -type f | cat > cscope.files
#find . -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" > cscope.files
cscope -bqR