您的位置:首页 > 编程语言 > Python开发

vim as python IDE

2015-04-28 19:38 309 查看
常用设置:

autocmd! BufWritePost ~/.vimrc source %
let mapleader=","
set nocompatible    " be iMproved, required
set number          " show line number
set showcmd         " Show (partial) command in status line.
set showmatch       " Show matching brackets.
set ignorecase      " Do case insensitive matching
set smartcase       " Do smart case matching
set incsearch       " Incremental search
set autowrite       " Automatically save before commands like :next         and :make
set hidden          " Hide buffers when they are abandoned
set mouse=a         " Enable mouse usage (all modes)
set bs=2            " make backspace behave like normal again

nnoremap <leader>n :bn<cr>
nnoremap <leader>p :bp<cr>
imap <C-e> <END>
nnoremap <leader>j <C-w>j
nnoremap <leader>k <C-w>k
nnoremap <leader>h <C-w>h
nnoremap <leader>l <C-w>l

" easier moving of code blocks
" Try to go into visual mode (v), thenselect several lines of code here and
" then press ``>`` several times.
vnoremap < <gv  " better indentation
vnoremap > >gv  " better indentation

set tw=79   " width of document (used by gd)
set nowrap  " don't automatically wrap on load
set fo-=t   " don't automatically wrap text when typing
set colorcolumn=80
highlight ColorColumn ctermbg=100

" Real programmers don't use TABs but spaces
set cindent
set smartindent
set expandtab
set sw=4
set sts=4
set ts=4
set pastetoggle=<F2>
autocmd FileType html,json,yaml setlocal shiftwidth=2 tabstop=2


自动补全-推荐使用
jedi+YouCompleteMe
:

安装vundle插件管理工具:

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle


设置vim配置:

filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'Auto-Pairs'
Plugin 'Valloric/YouCompleteMe'
Plugin 'davidhalter/jedi'
" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required


安装插件
jedi+YouCompleteMe
:启动Vim , Normal模式下输入:
:PluginInstall
YouCompleteMe 比较大下载比较慢,请耐心等待, YoucompleteMe 需要编译安装:

cd ~/.vim/bundle/YouCompleteMe
./install


配置
jedi+YouCompleteMe
:

jedi 配置

autocmd FileType python setlocal completeopt=longest
set pumheight=10
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#popup_on_dot = 1
let g:jedi#popup_select_first = 1
let g:jedi#documentation_command = "K"
let g:jedi#rename_command = "<leader>r"


YouCompleteMe 配置:

nnoremap <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
inoremap <Tab> <C-x><C-o>
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_complete_in_comments = 1
let g:ycm_complete_in_strings = 1
"注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_comments_and_strings = 0
let g:ycm_cache_omnifunc=0
let g:ycm_min_num_of_chars_for_completion=2
let g:ycm_collect_identifiers_from_tags_files=1


推荐插件:

Plugin 'scrooloose/nerdtree'      "文件浏览
Plugin 'Lokaltog/vim-powerline'   "状态栏美化
Plugin 'fholgado/minibufexpl.vim' "minibuf
Plugin 'ctrlp.vim'                "文件查找, 很强大
Plugin 'mattn/emmet-vim'          " vim 编辑html神器, 谁用谁知道
Plugin 'hynek/vim-python-pep8-indent' "插件名称说的很清除
Plugin 'nvie/vim-flake8'          " python代码检查工具, python对代码的规范要求很高, 想写出漂亮规范的代码, 这个必不可少;需要注意的是:它的配置文件不是~/.vimrc 而是~/.config/flake8
Plugin 'Markdown'                 " 吐槽, CSDN的Markdown不怎么好用
Plugin 'JSON.vim'
Plugin 'yaml.vim'                 " 现在有人在用yaml么, 比json写起来方便多了, 可以试试


以上这几插件没有很复杂的配置,用起来却方便很多,另外一些插件或是配置,请自行搜索;

更多插件介绍点这里

另外再推荐一个配色方案:

" 推荐一种配色方案:
" mkdir -p ~/.vim/colors && cd ~/.vim/colors
" wget -O wombat256mod.vim http://www.vim.org/scripts/download_script.php?src_id=13400 set t_Co=256
color wombat256mod
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python vim ide linux plugins