Linux VIM8 Python3 编辑器配置文件

Linux VIM8 Python3 编辑器配置文件

"---------------------简单配置-------------------------
set nocompatible       "关闭与vi的兼容模式
set number             "显示行号
set nowrap             "不自动折行
set showmatch          "显示匹配的括号
set scrolloff=3        "距离顶部和底部3行"
set encoding=utf-8     "编码
set fenc=utf-8         "编码
"set mouse=a            "启用鼠标
set hlsearch           "搜索高亮
syntax on              "语法高亮
set backspace=indent,eol,start "启动删除设置

"------------为py文件添加支持pep8风格的配置-------------
au BufNewFile,BufRead *.py
\ set tabstop=4        "tab宽度
\ set softtabstop=4 
\ set shiftwidth=4  
\ set textwidth=79     "行最大宽度
\ set expandtab        "tab替换为空格键
\ set autoindent       "自动缩进
\ set fileformat=unix  "保存文件格式

"-------分隔窗口将新窗口再右边或者下方打开,添加配置-----
set splitbelow
set splitright

"分割窗口参数
":vs  或者 :vsplit  将当前窗口竖直分割,并在上面新窗口中显示当前文件
":vs filename 将当前窗口竖直分割,新文件在新窗口中显示
":sp 或者:sv或者:split  将当前窗口水平分割,并在左边新窗口中显示当前文件
":sp filename 将当前窗口竖直分割,新文件在左边新窗口中显示
":new 新建文件并竖直分割
":vnew 新建文件并水平分割

"--------------添加头文件信息-------------------
function HeaderPython()
    call setline(1, "#!/usr/bin/env python")
    call append(1, "# -*- coding: utf-8 -*-")
    call append(2, "# Pw @ " . strftime('%Y-%m-%d %T', localtime()))
    normal G
    normal o
    normal o
endf
autocmd bufnewfile *.py call HeaderPython()

"--------------代码折叠配置-----------------------
set foldmethod=indent
set foldlevel=99

"使用zc按键来创建折叠,使用za来打开或者关闭折叠。
"za经常会误输入,空格快捷键来替代za:
nnoremap <space> za

"--------------一键执行python代码配置--------------
"按 F5 执行代码
map <F5> :call RunPython()<CR>
func! RunPython()
    exec "W"
    if &filetype == 'python'
        exec "!time python3 %"
    endif
endfunc

"-----------------Vundle 插件----------------------
set nocompatible              " be iMproved, required
filetype off                  " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"--------------------------------------------------
"      使用:PluginInstall下载下面的插件
"--------------------------------------------------
"
"  其他:常用命令 ↓
"
"  :PluginList          列出所有已配置的插件
"  :PluginInstall       安装插件,追加 ! 用以更新或使用 :PluginUpdate
"  :PluginSearch foo    搜索 foo ; 追加 ! 清除本地缓存
"  :PluginClean         清除未使用插件,需要确认; 追加 ! 自动批准移除未使用插件
"
"-----let Vundle manage Vundle, required-----------
Plugin 'VundleVim/Vundle.vim'

"YCM自动补全
Plugin 'Valloric/YouCompleteMe'

"vim8自动补全插件
Plugin 'maralla/completor.vim'
let g:completor_python_binary = '/usr/bin/python3'

"vim8自动缩进插件
Plugin 'vim-scripts/indentpython.vim' 

"vim8语法检查插件
Plugin 'vim-syntastic/syntastic'
"vim8添加flake8代码风格检查
Plugin 'nvie/vim-flake8'
" F2启用代码检查
autocmd FileType python map <buffer> <F2> :call Flake8()<CR>
"保存文件时显示错误
autocmd BufWritePost *.py call flake8#Flake8()

"配色方案1 vundle下载
Plugin 'altercation/vim-colors-solarized'
"light or dark 两种配色主题
syntax enable
set background=light

"树形目录
Plugin 'scrooloose/nerdtree'
"树形目录快捷键 ctrl + n
map <C-n> :NERDTreeToggle<CR>
"设置忽略文件
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
"为nerdtree添加git支持
Plugin 'Xuyuanp/nerdtree-git-plugin'
"如果你想用tab键
Plugin 'jistr/vim-nerdtree-tabs'

"美化栏
Plugin 'Lokaltog/vim-powerline'

"缩进指示线  | 开关:IndentLinesToggle
Plugin 'Yggdroot/indentLine'

"自动格式化工具 | 运行:Autopep8 |效果自动一招pep8标准自动格式化代码
Plugin 'tell-k/vim-autopep8'
"设置快捷键F8代替:Autopep8
autocmd FileType python noremap <buffer> <F8> :call Autopep8()<CR>

"自动补全括号引号等
Plugin 'jiangmiao/auto-pairs'

"搜索插件 | ctrl+p 然后输入你要寻找的文件就行了
Plugin 'kien/ctrlp.vim'

"搜索引擎使用了 the_silver_searcher 
"使用:Ag [options] {pattern} [{directory}]
Plugin 'rking/ag.vim'

"git集成插件 | vim内运行git命令
Plugin 'tpope/vim-fugitive'

"--------------------------------------------
call vundle#end()            " required
filetype plugin indent on    " required
"--------------------------------------------

猜你喜欢

转载自www.cnblogs.com/xiangsikai/p/11057905.html