内容包含
vim-plug,异步插件管理,总之就是下起来快。
ale,异步语法检查
LeaderF,快速查找文件
completor.vim vim8的快速补全
markdown预览
common setting
startup开始
使打开vimrc折叠,默认折叠是{{{
" Startup {{{
filetype indent plugin on
augroup vimrcEx
au!
autocmd FileType text setlocal textwidth=78
augroup END
" vim 文件折叠方式为 marker
augroup ft_vim
au!
autocmd FileType vim setlocal foldmethod=marker
" 打开文件总是定位到上次编辑的位置
autocmd BufReadPost *
if line("'"") > 1 && line("'"") <= line("$") |
exe "normal! g`"" |
endif
augroup END
" }}}
General常用
" General {{{
set nocompatible
set nobackup
set noswapfile
set history=1024
"自动设置当前目录为正在编辑的目录
cd D:CodeVimCode
set autochdir
autocmd BufEnter * silent! lcd %:p:h:gs/ /\ /
set whichwrap=b,s,<,>,[,]
set nobomb
set backspace=indent,eol,start whichwrap+=<,>,[,]
" Vim 的默认寄存器和系统剪贴板共享
set clipboard+=unnamed
" 设置 alt 键不映射到菜单栏
set winaltkeys=no
"关闭提示音
set noeb
set vb t_vb=
" }}}
Lang语言编码
" Lang & Encoding {{{
set fenc=
set fileencodings=utf-8,gb18030,utf-16,big5
set encoding=utf-8
set langmenu=zh_CN
let $LANG = 'en_US.UTF-8'
"解决consle输出乱码
language messages zh_CN.utf-8
"解决菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" }}}
GUI界面
" GUI {{{
" 设置 gvim 显示字体
"set guifont=DejaVu Sans Mono for Powerline:h12
set guifont=Fira_Code:h12
set gfw=幼圆:h12:cGB2312
set cursorline
set hlsearch
" 开启实时搜索功能
set incsearch
" 搜索时大小写不敏感
set ignorecase
set number
"Show related row numbers
set relativenumber
"在光标接近底端或顶端时,自动下滚或上滚
set scrolloff=10
" 窗口大小
set lines=30 columns=80
" 分割出来的窗口位于当前窗口下边/右边
set splitbelow
set splitright
"不显示工具/菜单栏
set guioptions-=T
set guioptions-=m
set guioptions-=L
set guioptions-=r
set guioptions-=b
" }}}
Format格式
" Format {{{
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
"自动折叠
set foldmethod=marker
syntax on
" }}}
Keyboard setting 映射
" Keyboard setting {{{
"set my leader
"let mapleader=";"
let mapleader="<Space>"
"打开vimrc快捷键
nnoremap <leader>ev :split $MYVIMRC<cr>
"运行当前vimrc脚本
nnoremap<leader>sv :source $MYVIMRC<cr>
" 打开当前目录 windows
nmap <silent> <leader>ex :!start explorer %:p:h<CR>
" 打开当前目录CMD
nmap <silent> <leader>cmd :!start cmd /k cd %:p:h<cr>
" 复制当前文件/路径到剪贴板
nmap ,fn :let @*=substitute(expand("%"), "/", "\", "g")<CR>
nmap ,fp :let @*=substitute(expand("%:p"), "/", "\", "g")<CR>
" 一键运行
"编译运行
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "! %<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "! %<"
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
elseif &filetype == 'py'
exec "!python"
elseif &filetype == 'sh'
:!%
endif
endfunc
" }}}
Plug List & setting
注意,以下插件都要在call plug#begin('D:EditorVimvimfilesplugged')
中写入,路径可以改为你要放的插件文件夹路径
美化插件
" +beautiful {{{
"美化状态栏
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" airline-setting {{{
"加强版状态栏
let g:airline_theme='molokai'
"使用powerline打过补丁的字体
let g:airline_powerline_fonts = 1
"关闭状态显示空白符号计数,这个对我用处不大"
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#whitespace#symbol = '!'
"开启tabline
let g:airline#extensions#tabline#enabled = 1
"tabline中buffer显示编号
let g:airline#extensions#tabline#buffer_nr_show = 1
" }}}
"打开界面
Plug 'mhinz/vim-startify'
"theme color
Plug 'flazz/vim-colorschemes'
Plug 'tomasr/molokai'
Plug 'morhetz/gruvbox'
Plug 'nanotech/jellybeans.vim'
" theme-setting {{{
" 配色方案
set background=dark
"colorscheme jellybeans
"colorscheme molokai
"colorscheme desert
colorscheme gruvbox
" }}}
"中文帮助文档
Plug 'yianwillis/vimcdoc'
"}}}
编写插件,nerdtree,ale,LeaderF等
" +programming {{{
"文件树
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
" 文件树设置 {{{
" 关闭NERDTree快捷键
map <leader>t :NERDTreeToggle<CR>
""当NERDTree为剩下的唯一窗口时自动关闭
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
""修改树的显示图标
let g:NERDTreeDirArrowExpandable = '►'
let g:NERDTreeDirArrowCollapsible = '▼'
let NERDTreeAutoCenter=1
" 显示行号
let NERDTreeShowLineNumbers=1
" 是否显示隐藏文件
let NERDTreeShowHidden=1
" 设置宽度
let NERDTreeWinSize=25
" 在终端启动vim时,共享NERDTree
let g:nerdtree_tabs_open_on_console_startup=1
" 忽略一下文件的显示
let NERDTreeIgnore=['.pyc','~$','.swp']
let g:NERDTreeIndicatorMapCustom = {
"Modified" : "✹",
"Staged" : "✚",
"Untracked" : "✭",
"Renamed" : "➜",
"Unmerged" : "═",
"Deleted" : "✖",
"Dirty" : "✗",
"Clean" : "✔︎",
'Ignored' : '☒',
"Unknown" : "?"
}
" }}}
"文件搜索
Plug 'Yggdroot/LeaderF'
"异步语法检查
Plug 'w0rp/ale'
" ale-setting {{{
let g:ale_set_highlights = 0
"自定义error和warning图标
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚡'
"在vim自带的状态栏中整合ale
let g:ale_statusline_format = ['✗ %d', '⚡ %d', '✔ OK']
"显示Linter名称,出错或警告等相关信息
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
"打开文件时不进行检查
let g:ale_lint_on_enter = 0
"普通模式下,sp前往上一个错误或警告,sn前往下一个错误或警告
nmap sp <Plug>(ale_previous_wrap)
nmap sn <Plug>(ale_next_wrap)
"<Leader>s触发/关闭语法检查
nmap <Leader>s :ALEToggle<CR>
"<Leader>d查看错误或警告的详细信息
nmap <Leader>d :ALEDetail<CR>
"使用clang对c和c++进行语法检查,对python使用pylint进行语法检查
let g:ale_linters = {
'c++': ['clang'],
'c': ['clang'],
'python': ['pylint'],
}
" }}}
"括号补全
Plug 'jiangmiao/auto-pairs'
"补全
Plug 'maralla/completor.vim'
Plug 'maralla/completor-neosnippet'
" 补全设置 {{{
"使用tab补全
inoremap <expr> <Tab> pumvisible() ? "<C-n>" : "<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "<C-p>" : "<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "<C-y><cr>" : "<cr>"
" }}}
"注释
Plug 'scrooloose/nerdcommenter'
" 注释说明 {{{
"<leader>cc 加注释
"<leader>cu 解开注释
"<leader>c<space> 加上/解开注释, 智能判断
"<leader>cy 先复制, 再注解(p可以进行黏贴)
" 注释的时候自动加个空格, 强迫症必配
"let g:NERDSpaceDelims=1
" }}}
"}}}
语言插件
" +lag {{{
" markdown
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'kannokanno/previm'
Plug 'tyru/open-browser.vim'
" markdown-setting {{{
"使用:PrevimOpen就可以预览
" }}}
插件汇总
" PluList {{{
call plug#begin('D:EditorVimvimfilesplugged')
filetype plugin indent on
" +beautiful {{{
"美化状态栏
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" airline-setting {{{
"加强版状态栏
let g:airline_theme='molokai'
"使用powerline打过补丁的字体
let g:airline_powerline_fonts = 1
"关闭状态显示空白符号计数,这个对我用处不大"
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#whitespace#symbol = '!'
"开启tabline
let g:airline#extensions#tabline#enabled = 1
"tabline中buffer显示编号
let g:airline#extensions#tabline#buffer_nr_show = 1
" }}}
"打开界面
Plug 'mhinz/vim-startify'
"theme color
Plug 'flazz/vim-colorschemes'
Plug 'tomasr/molokai'
Plug 'morhetz/gruvbox'
Plug 'nanotech/jellybeans.vim'
" theme-setting {{{
" 配色方案
set background=dark
"colorscheme jellybeans
"colorscheme molokai
"colorscheme desert
colorscheme gruvbox
" }}}
"中文帮助文档
Plug 'yianwillis/vimcdoc'
"}}}
" +programming {{{
"文件树
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
" 文件树设置 {{{
" 关闭NERDTree快捷键
map <leader>t :NERDTreeToggle<CR>
""当NERDTree为剩下的唯一窗口时自动关闭
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
""修改树的显示图标
let g:NERDTreeDirArrowExpandable = '►'
let g:NERDTreeDirArrowCollapsible = '▼'
let NERDTreeAutoCenter=1
" 显示行号
let NERDTreeShowLineNumbers=1
" 是否显示隐藏文件
let NERDTreeShowHidden=1
" 设置宽度
let NERDTreeWinSize=25
" 在终端启动vim时,共享NERDTree
let g:nerdtree_tabs_open_on_console_startup=1
" 忽略一下文件的显示
let NERDTreeIgnore=['.pyc','~$','.swp']
let g:NERDTreeIndicatorMapCustom = {
"Modified" : "✹",
"Staged" : "✚",
"Untracked" : "✭",
"Renamed" : "➜",
"Unmerged" : "═",
"Deleted" : "✖",
"Dirty" : "✗",
"Clean" : "✔︎",
'Ignored' : '☒',
"Unknown" : "?"
}
" }}}
"文件搜索
Plug 'Yggdroot/LeaderF'
"异步语法检查
Plug 'w0rp/ale'
" ale-setting {{{
let g:ale_set_highlights = 0
"自定义error和warning图标
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚡'
"在vim自带的状态栏中整合ale
let g:ale_statusline_format = ['✗ %d', '⚡ %d', '✔ OK']
"显示Linter名称,出错或警告等相关信息
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
"打开文件时不进行检查
let g:ale_lint_on_enter = 0
"普通模式下,sp前往上一个错误或警告,sn前往下一个错误或警告
nmap sp <Plug>(ale_previous_wrap)
nmap sn <Plug>(ale_next_wrap)
"<Leader>s触发/关闭语法检查
nmap <Leader>s :ALEToggle<CR>
"<Leader>d查看错误或警告的详细信息
nmap <Leader>d :ALEDetail<CR>
"使用clang对c和c++进行语法检查,对python使用pylint进行语法检查
let g:ale_linters = {
'c++': ['clang'],
'c': ['clang'],
'python': ['pylint'],
}
" }}}
"括号补全
Plug 'jiangmiao/auto-pairs'
"补全
Plug 'maralla/completor.vim'
Plug 'maralla/completor-neosnippet'
" 补全设置 {{{
"使用tab补全
inoremap <expr> <Tab> pumvisible() ? "<C-n>" : "<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "<C-p>" : "<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "<C-y><cr>" : "<cr>"
" }}}
"注释
Plug 'scrooloose/nerdcommenter'
" 注释说明 {{{
"<leader>cc 加注释
"<leader>cu 解开注释
"<leader>c<space> 加上/解开注释, 智能判断
"<leader>cy 先复制, 再注解(p可以进行黏贴)
" 注释的时候自动加个空格, 强迫症必配
"let g:NERDSpaceDelims=1
" }}}
"}}}
" +lang {{{
" markdown
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'kannokanno/previm'
Plug 'tyru/open-browser.vim'
" markdown-setting {{{
"使用:PrevimOpen就可以预览
" }}}
"}}}
call plug#end()
" }}}
代码
可能有更新,可以看我github上的vimrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" common setting "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Startup {{{
filetype indent plugin on
augroup vimrcEx
au!
autocmd FileType text setlocal textwidth=78
augroup END
" vim 文件折叠方式为 marker
augroup ft_vim
au!
autocmd FileType vim setlocal foldmethod=marker
" 打开文件总是定位到上次编辑的位置
autocmd BufReadPost *
if line("'"") > 1 && line("'"") <= line("$") |
exe "normal! g`"" |
endif
augroup END
" }}}
" General {{{
set nocompatible
set nobackup
set noswapfile
set history=1024
"自动设置当前目录为正在编辑的目录
cd D:CodeVimCode
set autochdir
autocmd BufEnter * silent! lcd %:p:h:gs/ /\ /
set whichwrap=b,s,<,>,[,]
set nobomb
set backspace=indent,eol,start whichwrap+=<,>,[,]
" Vim 的默认寄存器和系统剪贴板共享
set clipboard+=unnamed
" 设置 alt 键不映射到菜单栏
set winaltkeys=no
"关闭提示音
set noeb
set vb t_vb=
" }}}
" Lang & Encoding {{{
set fenc=
set fileencodings=utf-8,gb18030,utf-16,big5
set encoding=utf-8
set langmenu=zh_CN
let $LANG = 'en_US.UTF-8'
"解决consle输出乱码
language messages zh_CN.utf-8
"解决菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" }}}
" GUI {{{
" 设置 gvim 显示字体
"set guifont=DejaVu Sans Mono for Powerline:h12
set guifont=Fira_Code:h12
set gfw=幼圆:h12:cGB2312
set cursorline
set hlsearch
" 开启实时搜索功能
set incsearch
" 搜索时大小写不敏感
set ignorecase
set number
"Show related row numbers
set relativenumber
"在光标接近底端或顶端时,自动下滚或上滚
set scrolloff=10
" 窗口大小
set lines=30 columns=80
" 分割出来的窗口位于当前窗口下边/右边
set splitbelow
set splitright
"不显示工具/菜单栏
set guioptions-=T
set guioptions-=m
set guioptions-=L
set guioptions-=r
set guioptions-=b
" }}}
" Format {{{
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
"自动折叠
set foldmethod=marker
syntax on
" }}}
" Keyboard setting {{{
"set my leader
"let mapleader=";"
let mapleader="<Space>"
"打开vimrc快捷键
nnoremap <leader>ev :split $MYVIMRC<cr>
"运行当前vimrc脚本
nnoremap<leader>sv :source $MYVIMRC<cr>
" 打开当前目录 windows
nmap <silent> <leader>ex :!start explorer %:p:h<CR>
" 打开当前目录CMD
nmap <silent> <leader>cmd :!start cmd /k cd %:p:h<cr>
" 复制当前文件/路径到剪贴板
nmap ,fn :let @*=substitute(expand("%"), "/", "\", "g")<CR>
nmap ,fp :let @*=substitute(expand("%:p"), "/", "\", "g")<CR>
" 一键运行
"编译运行
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "! %<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "! %<"
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
elseif &filetype == 'py'
exec "!python"
elseif &filetype == 'sh'
:!%
endif
endfunc
" }}}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plug "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plug List {{{
call plug#begin('D:EditorVimvimfilesplugged')
filetype plugin indent on
" +beautiful {{{
"美化状态栏
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" airline-setting {{{
"加强版状态栏
let g:airline_theme='molokai'
"使用powerline打过补丁的字体
let g:airline_powerline_fonts = 1
"关闭状态显示空白符号计数,这个对我用处不大"
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#whitespace#symbol = '!'
"开启tabline
let g:airline#extensions#tabline#enabled = 1
"tabline中buffer显示编号
let g:airline#extensions#tabline#buffer_nr_show = 1
" }}}
"打开界面
Plug 'mhinz/vim-startify'
"theme color
Plug 'flazz/vim-colorschemes'
Plug 'tomasr/molokai'
Plug 'morhetz/gruvbox'
Plug 'nanotech/jellybeans.vim'
" theme-setting {{{
" 配色方案
set background=dark
"colorscheme jellybeans
"colorscheme molokai
"colorscheme desert
colorscheme gruvbox
" }}}
"中文帮助文档
Plug 'yianwillis/vimcdoc'
"}}}
" +programming {{{
"文件树
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
" 文件树设置 {{{
" 关闭NERDTree快捷键
map <leader>t :NERDTreeToggle<CR>
""当NERDTree为剩下的唯一窗口时自动关闭
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
""修改树的显示图标
let g:NERDTreeDirArrowExpandable = '►'
let g:NERDTreeDirArrowCollapsible = '▼'
let NERDTreeAutoCenter=1
" 显示行号
let NERDTreeShowLineNumbers=1
" 是否显示隐藏文件
let NERDTreeShowHidden=1
" 设置宽度
let NERDTreeWinSize=25
" 在终端启动vim时,共享NERDTree
let g:nerdtree_tabs_open_on_console_startup=1
" 忽略一下文件的显示
let NERDTreeIgnore=['.pyc','~$','.swp']
let g:NERDTreeIndicatorMapCustom = {
"Modified" : "✹",
"Staged" : "✚",
"Untracked" : "✭",
"Renamed" : "➜",
"Unmerged" : "═",
"Deleted" : "✖",
"Dirty" : "✗",
"Clean" : "✔︎",
'Ignored' : '☒',
"Unknown" : "?"
}
" }}}
"文件搜索
Plug 'Yggdroot/LeaderF'
"异步语法检查
Plug 'w0rp/ale'
" ale-setting {{{
let g:ale_set_highlights = 0
"自定义error和warning图标
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚡'
"在vim自带的状态栏中整合ale
let g:ale_statusline_format = ['✗ %d', '⚡ %d', '✔ OK']
"显示Linter名称,出错或警告等相关信息
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
"打开文件时不进行检查
let g:ale_lint_on_enter = 0
"普通模式下,sp前往上一个错误或警告,sn前往下一个错误或警告
nmap sp <Plug>(ale_previous_wrap)
nmap sn <Plug>(ale_next_wrap)
"<Leader>s触发/关闭语法检查
nmap <Leader>s :ALEToggle<CR>
"<Leader>d查看错误或警告的详细信息
nmap <Leader>d :ALEDetail<CR>
"使用clang对c和c++进行语法检查,对python使用pylint进行语法检查
let g:ale_linters = {
'c++': ['clang'],
'c': ['clang'],
'python': ['pylint'],
}
" }}}
"括号补全
Plug 'jiangmiao/auto-pairs'
"补全
Plug 'maralla/completor.vim'
Plug 'maralla/completor-neosnippet'
" 补全设置 {{{
"使用tab补全
inoremap <expr> <Tab> pumvisible() ? "<C-n>" : "<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "<C-p>" : "<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "<C-y><cr>" : "<cr>"
" }}}
"注释
Plug 'scrooloose/nerdcommenter'
" 注释说明 {{{
"<leader>cc 加注释
"<leader>cu 解开注释
"<leader>c<space> 加上/解开注释, 智能判断
"<leader>cy 先复制, 再注解(p可以进行黏贴)
" 注释的时候自动加个空格, 强迫症必配
"let g:NERDSpaceDelims=1
" }}}
"}}}
" +lang {{{
" markdown
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'kannokanno/previm'
Plug 'tyru/open-browser.vim'
" markdown-setting {{{
"使用:PrevimOpen就可以预览
" }}}
"}}}
call plug#end()
" }}}