在編輯python腳本時一些比較有用的配置:
首先打開,vim配置文件:
vi ~/.vimrc
可以選擇性的加入以下代碼,也可全加,:wq 保存即可。(註釋去掉)
# 解決中文顯示問題
set fencs=ucs-bom,utf-8,cpb936,gb18030,big5,euc-jp,euc-kr,latin1
set termencoding=utf-8
set enc=utf-8
# python相關設置
set filetype=python
au BufNewFile,BufRead *.py,*.pyw setf python
set number # 設置顯示行號
set tabstop=4 # 設置tab爲4個空格
set autoindent # 智能對齊
set autoread # 文件被修改時,自動重新讀取
set smartindent 智能對齊
set shiftwidth=4
# 括號自動補全
inoremap ' ''<ESC>i
inoremap " ""<ESC>i
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {<CR>}<ESC>O
瞭解更多,可登陸lichangsong.win