vim配置python开发环境_GitHub - TTWShell/legolas-vim: Vim配置,为python、go开发者打造的IDE。...
legolas-vim
個人vim配置。支持python、go等自動提示,支持python、go的函數(shù)跳轉(zhuǎn)(python支持虛擬環(huán)境)。 最終效果圖(函數(shù)列表的feature已移除,因為大項目會導(dǎo)致性能問題):
支持Python自動補(bǔ)全的最好插件是YouCompleteMe。而YouCompleteMe需要比較高版本的vim(>=7.4.143),所以,需要編譯安裝vim,參見相關(guān)文檔[1]。另外還需要一些C庫,參見相關(guān)文檔[2]。
vim擴(kuò)展管理器使用的是異步工具vim-plug。
由于是為python開發(fā)打造。默認(rèn)安裝了pip等py開發(fā)必需品。公用開發(fā)工具默認(rèn)安裝(brew、zsh等)。
Install & Update
支持Ubuntu、Centos(需要先處理下問題5 sudo vim的問題)、Mac OSX(默認(rèn)基于brew安裝新版vim),一鍵安裝:
cd ~ && rm -rf legolas-vim && git clone https://github.com/TTWShell/legolas-vim.git && cd legolas-vim && bash install.sh INIT
如果用戶修改了vimrc配置文件,運(yùn)行以下命令更新即可:
./install-plugins.sh install
升級插件:
./install-plugins.sh update
重新build YCM(參數(shù)自定義):
./install-plugins.sh rebuild --clang-completer --gocode-completer
安裝完成后后,可以通過修改HOME目錄下的.vimrc.local來覆蓋默認(rèn)的vimrc配置。
問題集錦
安裝過程中打開vim可能會提示找不到syntax.vim或者配色。syntax做一下ln s 操作即可。配色安裝完畢會自動解決。
mac上有好用的brew。可以直接安裝8.0以上版本的vim。可參考Mac環(huán)境配置及python包安裝的那些坑:
brew update
export PATH=/usr/local/bin:$PATH # 在/etc/profile 添加一下語句(使用zsh的在~/.zshrc添加即可)
mac由于并沒有直接替換系統(tǒng)自帶的vim。所以其他需要vim支持的工具需要修改配置。例如git:
git config --global core.editor "/usr/local/bin/vim"
關(guān)于字體
powerline-fonts已經(jīng)去掉了monaco_for_powerline。但是iterm2默認(rèn)字體monaco非常好看,為了使用monaco并解決特殊符號亂碼問題,所以Backup了一份。會自動安裝。用戶手動設(shè)置下iterm2字體配置即可(可搜索)。
關(guān)于centos 使用sudo的問題(sudo: vim: command not found)
局域網(wǎng)安裝問題
箭頭不是真的有箭頭,只是把tab顯示為箭頭,為的是查錯方便,這樣一眼就能看到有tab,而不是等到執(zhí)行程序時候發(fā)現(xiàn)報錯;
文件本身有tab、使用paste模式復(fù)制了代碼、在paste模式使用整體縮進(jìn)快捷鍵才會引入tab;
把tab一鍵替換為4空格的方法:
:retab
:w 保存文件可能會慢的情況,F6關(guān)閉語法檢查。
golang第三方庫自動補(bǔ)全無效:
執(zhí)行vim-go命令 :GoInstallBinaries即可修復(fù),可能報錯:
錯誤信息: vim-go: gogetdoc not found. Installing github.com/zmb3/gogetdoc to folder /usr/local/opt/go/libexec/bin
xxx timeout
可能的原因是PATH配置錯誤,需要加上$GOPATH/bin。即:
git clone https://github.com/golang/tools $GOPATH/golang.org/x/tools # 直接安裝gotools
export PATH=$GOPATH/bin:$PATH
怎么關(guān)閉文檔實時預(yù)覽:
If you don't want this window to ever show up, add set completeopt-=preview to your vimrc. Also make sure that the g:ycm_add_preview_to_completeopt option is set to 0.
在vim啟動時提示 The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code -11. Type ':YcmToggleLogs ycmd_52907_stderr_R736k6.log' to check the logs:
可能是因為安裝腳本使用的是anaconda提供的python編譯YouCompleteMe導(dǎo)致的,暫時修改環(huán)境變量讓python命令指向的不是anaconda的python或者修改install-plugin.sh里面rebuild函數(shù)中的python install.py將python改為絕對路徑均可。相關(guān)issue
關(guān)于其他插件使用問題,建議直接查詢文檔,如果你覺得是一個常見問題/需要花時間去處理的問題,歡迎提pr,我會審核,然后合并到master。
快捷鍵說明
NERDTree有按橫向縱向布局模式打開文件的快捷,直接看help信息即可。
tab切換使用ngt即可。例如切換到第二個tab頁,輸入2gt。
支持pycharm中的代碼塊縮進(jìn)操作(使用tab、s-Tab)。
支持全局搜索替換(多個文件搜索替換)。
自定義快捷鍵
命令
說明
sv
打開一個文件,縱向分割布局(新文件會在當(dāng)前文件下方界面打開)
vs
橫向分割布局(新文件會在當(dāng)前文件右側(cè)界面打開)
Ctrl-h
切換到左側(cè)的分割窗口
Ctrl-j
切換到下方的分割窗口
Ctrl-l
切換到右側(cè)的分割窗口
Ctrl-k
切換到上方的分割窗口
Alt-h
減小當(dāng)前窗口的寬度
Alt-j
減小當(dāng)前窗口的高度
Alt-l
增加當(dāng)前窗口的高度
Alt-k
增加當(dāng)前窗口的寬度
Ctrl-g
跳轉(zhuǎn)到函數(shù)定義或者聲明
Ctrl-y,
emmet自動補(bǔ)全快捷
--
--
F2
打開or關(guān)閉行號,同時打開or關(guān)閉gitgutter(文件變化提示)
F3
打開or關(guān)閉復(fù)制支持
F4
折疊or展開代碼(默認(rèn)打開文件不折疊)
F5
打開or關(guān)閉目錄樹
F6
打開or關(guān)閉語法檢查(大文件時影響性能)
F7
flake8 check
F8
Glog,展示文件的git history
F9
配合Glog,查看文件前一個版本
f10
配合Glog,查看文件后一個版本
--
--
space
折疊/展開代碼
--
--
Shift-i
目錄是否顯示隱藏文件(NERDTree)。便于git開發(fā),默認(rèn)永遠(yuǎn)不顯示.git。
跳轉(zhuǎn)
命令
說明
Ctrl-o
jump back to where you where before invoking the command 和 Ctrl-g、ctrl-i 配合使用
ctrl-i
jump forward
ctrl-^
跳轉(zhuǎn)到上一個編輯的文件
--
--
zz
move current line to the middle of the screen
zt
move current line to the top of the screen
zb
move current line to the bottom of the screen
搜索
命令
說明
:/pattern
搜索所有包含pattern的單詞(向上搜索)
:?pattern
搜索所有包含pattern的單詞(向下搜索)
n
朝同一方向搜索
N
反方向搜索
:/ pattern
單詞前加空格,精確匹配
:/^pattern
搜索僅在行首出現(xiàn)
:/pattern$
搜索僅在行末出現(xiàn)
\^ \$
特殊字符的搜索加反斜杠
搜索替換
命令
說明
:s/foo/bar/g
Change each 'foo' to 'bar' in the current line.
:%s/foo/bar/g
Change each 'foo' to 'bar' in all the lines.
:5,12s/foo/bar/g
Change each 'foo' to 'bar' for all lines from line 5 to line 12 (inclusive).
:'a,'bs/foo/bar/g
Change each 'foo' to 'bar' for all lines from mark a to mark b inclusive (see Note below).
:'<,'>s/foo/bar/g
When compiled with +visual, change each 'foo' to 'bar' for all lines within a visual selection. Vim automatically appends the visual selection range ('<,'>) for any ex command when you select an area and enter :. Also, see Note below.
:.,$s/foo/bar/g
Change each 'foo' to 'bar' for all lines from the current line (.) to the last line ($) inclusive.
:.,+2s/foo/bar/g
Change each 'foo' to 'bar' for the current line (.) and the two next lines (+2).
:g/^baz/s/foo/bar/g
Change each 'foo' to 'bar' in each line starting with 'baz'.
--
--
:arg *.py
All *.py files in current directory.
:argadd *.md
And all *.md files.
:arg
Optional: Display the current arglist.
:argdo %s/pattern/replace/ge | update
Search and replace in all files in arglist.
刪除
命令
說明
x
刪除當(dāng)前光標(biāo)處的字符
X
刪除光標(biāo)左邊的字符
D
刪除從當(dāng)前光標(biāo)到本行末尾的字符
J
刪除兩行之間的換行符 (亦可用于合并兩行)
dmove
刪除從當(dāng)前光標(biāo)到move所給位置的字符
dd
刪除當(dāng)前行
:lined
刪除指定行
:line,lined
刪除指定范圍內(nèi)的行
咖啡
收到幾個網(wǎng)友請喝咖啡的私信😊😊😊,附上支付寶。
相關(guān)文檔
總結(jié)
以上是生活随笔為你收集整理的vim配置python开发环境_GitHub - TTWShell/legolas-vim: Vim配置,为python、go开发者打造的IDE。...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android全局窗口模糊,javasc
- 下一篇: websocket python爬虫_p