在编辑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