vim as python IDE

  1. 常用设置:

    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
  2. 自动补全-推荐使用 jedi+YouCompleteMe:

    1. 安装vundle插件管理工具:
    git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
    1. 设置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
    2. 安装插件jedi+YouCompleteMe:启动Vim , Normal模式下输入::PluginInstall YouCompleteMe 比较大下载比较慢,请耐心等待, YoucompleteMe 需要编译安装:
    cd ~/.vim/bundle/YouCompleteMe
    ./install
    1. 配置jedi+YouCompleteMe:

      1. 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"
      1. 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
    2. 推荐插件:
    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
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值