基本參考:https://blog.csdn.net/qq_26877377/article/details/80717755
注意幾點:
(1)關於python的自動補全,不要使用pydiction插件。它使用的是字典補全,很老很局限;
(2)安裝博客中的插件時,python-mode比較大,耐心等待即可,安裝完之后還需要在.vimrc中添加下面:
"python-mode "開啟警告 let g:pymode_warnings = 0 "保存文件時自動刪除無用空格 let g:pymode_trim_whitespaces = 1 let g:pymode_options = 1 ""顯示允許的最大長度的列 let g:pymode_options_colorcolumn = 1 "設置QuickFix窗口的最大,最小高度 let g:pymode_quickfix_minheight = 3 let g:pymode_quickfix_maxheight = 10 "使用python3 let g:pymode_python = '~/anaconda3/envs/tensorflow/bin/python3' "使用PEP8風格的縮進 "let g:pymode_indent = 1 "啟用代碼折疊 "let g:pymode_folding = 1 "開啟python-mode定義的移動方式 "let g:pymode_motion = 1 "啟用python-mode內置的python文檔,使用K進行查找 let g:pymode_doc = 1 let g:pymode_doc_bind = 'K' "自動檢測並啟用virtualenv let g:pymode_virtualenv = 1 "不使用python-mode運行python代碼 let g:pymode_run = 0 "let g:pymode_run_bind = '<Leader>r' "不使用python-mode設置斷點 let g:pymode_breakpoint = 0 "let g:pymode_breakpoint_bind = '<leader>b' "啟用python語法檢查 let g:pymode_lint = 1 "修改后保存時進行檢查 let g:pymode_lint_on_write = 0 "編輯時進行檢查 let g:pymode_lint_on_fly = 0 let g:pymode_lint_checkers = ['pyflakes', 'pep8'] "發現錯誤時不自動打開QuickFix窗口 let g:pymode_lint_cwindow = 0 "側邊欄不顯示python-mode相關的標志 let g:pymode_lint_signs = 0 "let g:pymode_lint_todo_symbol = 'WW' "let g:pymode_lint_comment_symbol = 'CC' "let g:pymode_lint_visual_symbol = 'RR' ""let g:pymode_lint_error_symbol = 'EE' "let g:pymode_lint_info_symbol = 'II' "let g:pymode_lint_pyflakes_symbol = 'FF' "啟用重構 let g:pymode_rope = 1 "不在父目錄下查找.ropeproject,能提升響應速度 let g:pymode_rope_lookup_project = 0 "光標下單詞查閱文檔 let g:pymode_rope_show_doc_bind = '<C-c>d' "項目修改后重新生成緩存 let g:pymode_rope_regenerate_on_write = 1 "開啟補全,並設置<Tab>為默認快捷鍵 let g:pymode_rope_completion = 1 let g:pymode_rope_complete_on_dot = 1 let g:pymode_rope_completion_bind = '<Tab>' "<C-c>g跳轉到定義處,同時新建豎直窗口打開 let g:pymode_rope_goto_definition_bind = '<C-c>g' let g:pymode_rope_goto_definition_cmd = 'vnew' "重命名光標下的函數,方法,變量及類名 let g:pymode_rope_rename_bind = '<C-c>rr' "重命名光標下的模塊或包 let g:pymode_rope_rename_module_bind = '<C-c>r1r' "開啟python所有的語法高亮 let g:pymode_syntax = 1 let g:pymode_syntax_all = 1 "高亮縮進錯誤 let g:pymode_syntax_indent_errors = g:pymode_syntax_all "高亮空格錯誤 let g:pymode_syntax_space_errors = g:pymode_syntax_all
注意:let g:pymode_python中要填的是你的python解釋器的路徑,要正確!同時,如果使用anaconda的話,需要提前用“source activate xxx”來激活那個python解釋器的環境,再使用vim;(否則會報ommit completion,pattern not found的錯誤),這里的話就是“source activate pytorch”
(3)使用set autoindent自動縮進
完成上面操作,基本python開發就差不多了;