计算机 · 2021年12月26日 0

vim常用配置

显示行尾的空格,免得gerrit老是用红色警告我

/\s\+$

参考https://vim.fandom.com/wiki/Highlight_unwanted_spaces

参考vimrc文件

execute pathogen#infect()
:set nu
:set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
:syntax on
":set list
":set listchars=tab:>-,trail:.
:set colorcolumn=80
filetype on
autocmd Filetype c call SetCppOptions()
autocmd Filetype cpp call SetCppOptions()
autocmd Filetype python call SetPythonOptions()
nmap <F8> :TagbarToggle<CR>

"\u6309ctrl\u52a0\u5de6\u53f3\u952e\u6765\u5207\u6362tab,\u6309alt\u52a0\u5de6\u53f3\u952e\u6765\u79fb\u52a8tab
nnoremap <C-Left> :tabprevious<CR>
nnoremap <C-Right> :tabnext<CR>
nnoremap <silent> <A-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
nnoremap <silent> <A-Right> :execute 'silent! tabmove ' . (tabpagenr()+1)<CR>


:function SetCppOptions()
:	setlocal ts=4
:	setlocal foldmethod=syntax
:	setlocal expandtab
	setlocal foldlevel=4
	setlocal autoindent
	filetype plugin on
	set omnifunc=syntaxcomplete#Complete
	:call tagbar#autoopen(1)
:endfunction

:function SetPythonOptions()
:	setlocal ts=4
:	setlocal foldmethod=syntax
:	setlocal expandtab
	setlocal foldlevel=2
	setlocal autoindent
	filetype plugin on
	set omnifunc=syntaxcomplete#Complete
:endfunction

将已有的tab替换为空格

:retab

将输入的tab替换为空格

:set expandtab