python在linux上运行,使用的是vim,每次都是敲四个空格进行缩进,真尼玛的蛋疼,书本果然是个好东西,从而根据书本python高级编程中的设置配置而来:
1、进行自动补全的脚本
[root@python ~]# cat .pythonstartup #python startup file import readline import rlcompleter import atexit import os #tab completion readline.parse_and_bind('tab:complete') #history file histfile = os.path.join(os.environ['HOME'],'.pythonhistory') try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file,histfile) del os,histfile,readline,rlcompleter主要是用来进行命令自动补全,和linux中的是一样一样的
写好这个之后,必须配置环境变量,在bash_profile中新增一项,如果没有这个文件在RHEL系列中,那么就是别的家目录文件中:
[root@python ~]# cat .bash_profile |grep PYTHONS export PYTHONSTARTUP='.pythonstartup'写好上面的两部之后,记得重新登录,或者直接读取环境变量,从而可以使用上面的设置:
[root@python ~]# source .bash_profile
用来进行自动缩进,主要就是因为。。。需要打太多的空格来进行缩进,从而使用到的是vim的配置文件.vimrc
具体内容设置如下:
[root@python ~]# cat .vimrc set expandtab set textwidth=0 set tabstop=4 set softtabstop=4 set shiftwidth=4 set autoindent set smartindent set backspace=indent,eol,start set incsearch set ignorecase set ruler set wildmenu set commentstring= # %s set foldlevel=0 set clipboard+=unnamed syntax enable syntax on基本意思就是缩进的时候,使用的tab是四个空格,进行自动和只能缩进,增强搜索,并且忽略大小写,语法高亮
有了这个,再也不需要打无数个空格而烦恼,也不用说几个空格就是规范了。