使用环境
- deepin 15.11 stable
- anaconda3
配置步骤
安装vim-nox
$ sudo apt install vim-nox
$ vim --version | grep python3
# 输出结果有+python3则通过
安装jedi
$ pip list | grep jedi # 查看是否安装了jedi, anaconda3默认安装
$ pip install jedi
安装Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
配置vimrc
修改~/.vimrc文件
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'maralla/completor.vim' "代码补全
Plugin 'scrooloose/nerdtree' "树型目录
Plugin 'jistr/vim-nerdtree-tabs' "树型目录中使用tab键
Plugin 'Yggdroot/indentLine' "缩进指示线
Plugin 'tamlok/vim-markdown' "markdown插件
Plugin 'joker1007/vim-markdown-quote-syntax' "markdown代码高亮
Plugin 'iamcco/markdown-preview.vim' "markdown预览
Plugin 'iamcco/mathjax-support-for-mkdp'"markdown公式预览
Plugin 'majutsushi/tagbar' "文本大纲
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
let g:completor_python_binary = '/home/walker/anaconda3/bin/python3' "python3路径, jedi
let g:completor_clang_binary = '/usr/bin/clang'
let g:markdown_enable_spell_checking = 0 "禁用拼写检查
" let g:tagbar_ctags_bin = "/usr/bin/ctags"
let g:mkdp_path_to_chrome="google-chrome" "指定markdown默认浏览器
let g:mkdp_auto_close=0
nmap <F7> <Plug>MarkdownPreview "一键打开markdown预览
nmap <F8> <Plug>StopMarkdownPreview "关闭markdown预览
set nocompatible "关闭与vi的兼容模式
set number "显示行号
set cursorline "高亮当前行
set nowrap "不自动折行
set showmatch "显示匹配的括号
set encoding=utf-8 "编码
set fenc=utf-8 "编码
set mouse=a "启用鼠标
set hlsearch "搜索高亮
syntax on "语法高亮
set tabstop=4 "tab宽度
set softtabstop=4
set shiftwidth=4
set textwidth=79 "行最大宽度
set expandtab "tab替换为空格键
" set splitright "默认新窗口在右边打开
map <C-m> :NERDTreeToggle<CR>
nnoremap <C-J> <C-W><C-J> “切换到下方的分割窗口
nnoremap <C-K> <C-W><C-K> “切换到下方的分割窗口
nnoremap <C-L> <C-W><C-L> “切换到下方的分割窗口
nnoremap <C-H> <C-W><C-H> “切换到下方的分割窗口
nmap fw :w<CR>
nmap fq :q<CR>
nmap fwq :wq<CR>
" vs 当前窗口竖直分割
" sp 当前窗口水平分割
set splitbelow
set splitright
map <F5> :call RunPython()<CR> "一键执行代码
func! RunPython()
exec "W"
if &filetype == 'python'
exec "!time python3 %"
elseif &filetype == 'c'
exec "!gcc % -o %<"
exec "!time ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "!time ./%<"
endif
endfunc
inoremap ' ''<ESC>i
inoremap " ""<ESC>i
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
"inoremap { {<CR>}<ESC>O
inoremap { {}<ESC>i
autocmd BufNewFile *.py,*.sh,*.java,*c,*h,*.cpp exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1,"\#########################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: Yanming Ji")
call append(line(".")+2, "\# mail: 1225401399@qq.com")
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\# Description: ")
call append(line(".")+5, "\######################################################################$")
call append(line(".")+6, "\#!/bin/bash")
call append(line(".")+7, "")
elseif &filetype == 'python'
"call setline(1, "\#######################################")
call setline(1, "#!/home/walker/anaconda3/bin/python3")
call append(line("."), "\#coding=utf-8")
call append(line(".")+1, "\######################################################")
call append(line(".")+2, "\# > File Name: ".expand("%"))
call append(line(".")+3, "\# > Author: Yanming Ji")
call append(line(".")+4, "\# > Mail: 1225401399@qq.com")
call append(line(".")+5, "\# > Created Time: ".strftime("%c"))
call append(line(".")+6, "\# > Description: ")
call append(line(".")+7, "\######################################################")
call append(line(".")+8,"")
else
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: Yanming Ji")
call append(line(".")+2, " > Mail: 1225401399@qq.com")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " > Description: ")
call append(line(".")+5, " **********************************************************************/")
call append(line(".")+6, "")
endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
endfunc
安装vim插件
终端进入vim, 执行命令:PluginInstall