Python switching mode, vim Mode tab auto-completion

Source: Internet
Author: User
Tags set background

1. Automatic completion of switching mode

#登陆python交换模式, import the Sys module, sys.path view python search path

[Email protected] python]# Pythonpython 2.6.6 (r266:84292, Jan, 09:42:36) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] On Linux2type ' help ', ' copyright ', ' credits ' or ' license ' for more information.>>> import sys>>> Sys.pat h[', '/usr/lib64/python26.zip ', '/usr/lib64/python2.6 ', '/usr/lib64/python2.6/plat-linux2 ', '/usr/lib64/python2.6 /lib-tk ', '/usr/lib64/python2.6/lib-old ', '/usr/lib64/python2.6/lib-dynload ', '/usr/lib64/python2.6/site-packages ', '/usr/lib64/python2.6/site-packages/gtk-2.0 ', '/usr/lib/python2.6/site-packages ']>>>

#切换到python第三方模块搜索路径下, create a tab.py module file

[Email protected] python]# Cd/usr/lib64/python2.6/site-packages[[email protected] site-packages]# cat tab.py
#!/usr/bin/python#pyton startup Tabimport sysimport readlineimport rlcompleterimport atexitimport osreadline.parse_ And_bind (' tab:complete ') Histfile = Os.path.join (os.environ[' HOME '], '. Pythonhistory ') Try:readline.read_history_ File (histfile) except IOError:passatexit.register (readline.write_history_file,histfile) del Os,histfile,readline, Rlcompleter

#在交换模式下导入tab模块, the Test tab is padded

>>> Import tab,sys>>> sys.sys.__class__ (sys.executablesys.__delattr__ (sys.exit (Sys.__dict__ Sys.exitfunc (sys.__displayhook__ (sys.flagssys.__doc__ sys.float_info


2, VIM editing mode tab auto-completion


First download Vim in the tab third-party module, which also describes the detailed use of the method

Website address: http://rkulla.github.io/pydiction/

wget https://github.com/rkulla/pydiction/zipball/masterunzip-q mastercd rkulla-pydiction-41c7143/

Create (. Vim) folder in the host directory, on the official website, complete-dict and pydiction.py the two files can only be installed in the (. Vim) directory

[Email protected] rkulla-pydiction-41c7143]# mkdir ~/.vim[[email protected] rkulla-pydiction-41c7143]# \CP after/~/. Vim-r[[email protected] rkulla-pydiction-41c7143]# \CP complete-dict ~/.vim[[email protected] rkulla-pydiction-41c7143]# CD ~/.vim[[email protected]. vim]# TREE.├──AFTER│└──FTPLUGIN│└──PYTHON_PYDICTION.V Im└──complete-dict

Under the host directory, create a new file (. vimrc), open the filetype plugin, and specify the full path to the complete-dict:

[email protected]. vim]# vim ~/.VIMRC "python tab Completion" enable filetype plugin filetype plugin on "Specify Complete-dict full path let g:pydiction _location = ' ~/.vim/complete-dict ' Setting the height of the menu, default to 8let G:pydiction_menu_height = 3

Whether the test takes effect:

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= " Https://s4.51cto.com/wyfs02/M01/A4/EF/wKioL1m03TTTpVE3AAD89gE7wnQ554.png-wh_500x0-wm_3-wmp_4-s_3713158854.png " Title= "1.png" alt= "Wkiol1m03tttpve3aad89ge7wnq554.png-wh_50"/>

Note: Vim editing files are only for files with the suffix. py, or header information that is declared as Python at the beginning of the file (#!/usr/bin/python)


A personal Vim profile is attached:

Cat ~/.VIMRC

"Syntax highlighting syntax on" displays line numbers set number "Enable mouse set Mouse=aset Selection=exclusiveset selectmode=mouse,key" Listen file type filetype on " Record history number of rows set history=1000 "Underline highlight cursor row set Cursorline" background use black set Background=dark "First row Set Tab key to 4 spaces, second row set when rows are interleaved with 4 spaces set Tabstop=4 "Set auto indent length to 4" set shiftwidth=4 "in the lower right corner of the state line to display the cursor position set ruler" set encoding automatic recognition, Chinese quotation marks display set Fileencoding=uft-8set Ambiwidth=double "Setting highlighting search set Hlsearch" when searching, input the words of the verbatim Fugauliang set Incsearch "show parentheses match set Showmatch" bracket match display time is 1 (in a very second) set matchtime=1 "python tab Completion" enable filetype plugin filetype plugin on "Specify Complete-dict full path let g:pydiction_location = ' ~/.vim/ Complete-dict ' "Setting the height of the menu, default to 8let G:pydiction_menu_height = 3

This article is from the "Gen Y Rookie" blog, so be sure to keep this source http://zhangxinqi.blog.51cto.com/9668428/1964100

Python switching mode, vim Mode tab auto-completion

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.