The configuration file for Vim is/ETC/VIMRC, or the configuration file is created in the ~/directory:
Touch. VIMRC
Highlight settings in general, Vim for the recognition of the program is automatically set highlighting, if not can be added in the. VIMRC syntax on and can adjust the background of the highlight adaptation terminal, if the background is black set Background=dark this configuration only dark /light two parameters, and it does not change the color of the background, if you want to change the background highlight Normal Ctermfg=grey Ctermbg=blue is in the terminal with a blue background, if it is in the GUI highlight Normal guibg=black guifg=whitehttp://vimdoc.sourceforge.net/htmldoc/options.html# ' background '
Indentation settings you can add filetype indent plugin on to turn on automatic indentation for tab formatting set Modeline also add comments in Python file # vim:tabstop=8 Expandtab shiftwidth=4 Softtabstop=4 can also be manually formatted set tabstop=8 expandtab shiftwidth=4 softtabstop=4or:set ts=8 et sw=4 sts=4
If the above settings are not successful, set Tabstop=9set expandtabset shiftwidth=4set Softtabstop=4filetype indent on is available separately
The above configuration can be individually set for files identified as Python, create ~/.vim/ftplugin/python.vim and add entries set num Add goodness to automatically add header annotations/ETC/VIM/VIMRC must be vim, not 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 configuration python highlighting and indenting