vim风格指南

set nu "line
syntax on "高亮
syntax enable "高亮
filetype on "检测文件类型
set showmode "是否要显示 --INSERT-- 之类的字眼在左下角的状态栏
set showcmd "在屏幕右下角显示未完成的指令输入
set encoding=utf-8
set t_Co=256
set autoindent "自动对齐
set smartindent "设置智能对齐
set cursorline "下划线
set showmatch "高亮显示匹配括号
"set ignorecase "搜索忽略大小写
set history=1000
set laststatus=2 "显示文件名
set pastetoggle=aa "粘贴模式,防止格式乱

"当检测到一个文件已经在Vim之外被更改,并且它没有在Vim的内部被更改时,自动读取它
set autoread

"color"
colorscheme gruvbox
set background=dark

" 在搜索时,输入的词句的逐字符高亮(类似firefox的搜索)
set incsearch
set shiftwidth=4 "这个量是每行的缩进深度,一般设置成和tabstop一样的宽度"
set tabstop=4 "设置Tab显示的宽度,Python建议设置成4"

"缩进"
autocmd FileType python set expandtab
set smartindent "智能缩进"
set cindent "C语言风格缩进"
set autoindent "自动缩进"

"一键运行代码
nnoremap :w!:call CompileRunGcc()
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!time java %<"
elseif &filetype == 'sh'
echo "\n"
echo system('bash "' . expand('%') . '"')
echo "\n
"
elseif &filetype == 'python'
echo system('python3 "' . expand('%') . '"')
elseif &filetype == 'html'
exec "!firefox % &"
elseif &filetype == 'go'
exec "!go build %<"
exec "!time go run %"
elseif &filetype == 'mkd'
exec "!~/.vim/markdown.pl % > %.html &"
exec "!firefox %.html &"
endif
endfunc

posted @ 2020-03-10 11:33  hornets  阅读(205)  评论(1)    收藏  举报