vim+plugins成为python ide

1. 安装vim和配置.vimrc

  • debian默认不带vim,因此运行以下命令安装vim

    1
    $ apt-get install vim
  • 下载vim产检管理工具vundle并添加管理目录

    1
    2
    $ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
    $ mkdir -p ~/vundle/plugin_installed
  • vim配置文件~/.vimrc并保存:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    " enable what?
    set nocompatible

    " filetype off?

    filetype off

    " 4 vundle
    " set runtime path to include Vundle

    set rtp+=~/.vim/bundle/Vundle.vim

    " pass a path where plugin should be install
    call vundle#begin('~/vundle/plugin_installed')

    " let Vundle manage Vundle

    Plugin 'gmarik/Vundle.vim'
    " 4 folding the indent
    Plugin 'tmhedberg/SimpylFold'
    " 4 indent by pep8

    Plugin 'vim-scripts/indentpython.vim'
    " 4 the syntax checking when saving
    Plugin 'scrooloose/syntastic'
    " 4 pep8 style checking

    Plugin 'nvie/vim-flake8'
    " 4 background color
    Plugin 'altercation/vim-colors-solarized'
    " 4 file tree init input :NERDTree in vim

    Plugin 'scrooloose/nerdtree'
    " 4 search file
    Plugin 'kien/ctrlp.vim'
    " Add all the plugins here


    " All of the plugins must add before this line
    call vundle#end()

    " filetype again?

    filetype plugin indent on

    " end setting 4 vundle

    " 4 split screen

    " enable region of split
    set splitbelow
    set splitright

    " quick key

    " with key ctrl+j switch 2 left screen
    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>
    nnoremap <space> za

    " end setting 4 split screen


    " 4 folding
    set foldmethod=indent
    set foldlevel=99
    " enable the comment of folding part

    let g:SimpylFold_docstring_preview=1
    " end setting 4 folding

    " show line number

    set nu

    " show visual line under the cursor's line
    set cursorline

    " show the match part of the pair for [] {} and ()

    set showmatch

    " 4 python
    " enable all python syntax highlineting features only 4 .py file

    au BufNewFile,BufRead *.py
    " set tab 2 have 4 spaces
    \ set ts=4
    \ set softtabstop=4
    " shift lines by 4 spaces

    \ set shiftwidth=4
    \ set textwidth=79
    " set auto indent
    \ set autoindent
    " expand tabs into spaces

    \ set expandtab
    \ set fileformat=unix
    \set encoding=utf-8
    let python_hightlight_all = 1
    syntax on

    if has('gui_runing')
    set background=dark
    colorscheme solarized
    endif
    " to change bgc by F5
    call togglebg#map("<F5>")

  • 保存退出,重新打开并在vim下运行命令:PluginInstall完成插件安装

参考

  • 如果想用代码不全,还可以增加YouCompleteMe插件
  • 参考文献来自于这个那个网站