標籤:size bst set keyword pen time ftp 頭部 class
vim的設定檔在/etc/vimrc,或者在~/目錄下建立設定檔:
touch .vimrc
高亮設定一般來說vim對識別的程式是會自動化佈建高亮的,如果沒有可以在.vimrc中添加syntax on並且可以調節高亮顯示適配terminal的背景,如果背景是黑色set background=dark這個配置只有dark/light兩個參量,並且它並不改變背景的顏色,如果要改變背景highlight Normal ctermfg=grey ctermbg=blue就是在terminal中用藍底白字,如果是在gui中則highlight Normal guibg=black guifg=whitehttp://vimdoc.sourceforge.net/htmldoc/options.html#‘background‘
縮排設定可以添加filetype indent plugin on來開啟自動縮排對於tab的格式set modeline同時在python檔案中添加註釋# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4也可以手動設定格式set tabstop=8 expandtab shiftwidth=4 softtabstop=4Or:set ts=8 et sw=4 sts=4
如果上面的設定不成功可以單獨設定set tabstop=9set expandtabset shiftwidth=4set softtabstop=4filetype indent on
以上配置可以單獨對識別為python的檔案設定,建立~/.vim/ftplugin/python.vim並添加條目 set num 添加行好 自動添加頭部注釋/etc/vim/vimrc必須是vim,而不是vi function HeaderPython() call setline(1, "#!/usr/bin/env python") call append(1, "#-*- coding:utf8 -*-") call append(2, "# Power by WenBin" . strftime(‘%Y-%m-%d %T‘, localtime())) normal G normal o normal o endf autocmd bufnewfile *.py call HeaderPython()
vim配置python高亮和縮排