How to Use Vi programming 3 to add your own python VIMRC :)

Source: Internet
Author: User

It has been a while before the previous two logs have been written, and more are used, and several small functions are gradually discovered.

For the first two logs that you like VIM,

VI programming 1 http://www.cnblogs.com/amaoxiaozhu/archive/2012/03/23/2414007.html

VI programming 2 http://www.cnblogs.com/amaoxiaozhu/archive/2012/04/05/2423009.html

Well, let's just say, start a new journey:

1. Edit:

H m l top, middle, and bottom of the screen [do not bother thinking about 8j or 12j, just one click ~]

Gf: edit the file name at the cursor. [This is the most recommended file ~ Very powerful function!]

'. Last modified location

Ctrl + o | I cursor position backtracking

Ls | vi-edit MPs queue output

2. module:

The premise is that NERDTree ~ is installed ~

Use a module: vi-c NERDTree

To open a folder directly, you can use the vi. Or vi folder path.

 

3. hexadecimal

: %! Xxd converts the current text to hexadecimal. Big client Method

: %! Od converts the current text to an octal format.

: %! Xxd-r converts the current text to the text format.

: %! Hexdump converts the current text back to hexadecimal format and displays it in a small terminal mode.

Note: Memory display mode that can be understood by the small-end method (inaccurate ). The big-end method can be understood as the actual mode.

 

4. Other commands

% Indicates all rows of the file ,! Xxd indicates the combination of external commands, that is, when all the lines displayed on current vim are passed to xxd, the results after xxd processing are re-displayed on vim.

Sort files: gg = G

G to the end of the file

If you edit the encrypted file vi-x file in vim, the encrypted password is specified.

G; last modified location

Ctrl-c or [: exit the editing mode directly [amazing shortcut keys]

@: Repeat the last command.

"2 p: copy the content from the second time to the previous copy

 

5. Search

F. Search for characters in the same row (

; Repeat the last search c; modify to the next search character

Df deletes the content of a character from the same row.

: G/waf: Display All content containing waf lines

: G/waf/# display the row number at the same time

/<Ctrl-r> <ctrl-f> search for words at the cursor

/Keyword/1 move the cursor to the next line of the search word

/Keyword/e + 1 position the cursor at the end of the word search + 1

/Keyword/S-1 cursor positioned in the start position of the search word left-1

/<Ctrl-r>/else last searched word + else

3ft search for the third 'T' in the row'

 

6. Generate tags for python code

In the tools/scripts PATH, there is a tags generator ptags. py specifically provided by python for VI.

In my environment, I configured tags in this way:

1. Generate the python library in your Development Directory

     python ptags.py $(find . /usr/lib/python2.5/ -name '*.py'|grep -v 'git') 

[Git library is rarely found, leave it]

2. Edit. vimrc

  set tags=tags;      set autochdir

First, use the current directory to obtain the tags. [later development, you can generate a sub-tags in the new directory]

Otherwise, the search continues.

 

Appendix: If you are also a python coder ~ Claw grip

Set autoindentset syntax = onset nocpset softtabstop = 4 filetype plugin oncolorscheme IDLElet g: pydiction_location = '/root/conf/vi/complete-dict' let Tlist_Show_One_File = 1let versions = 1let Tlist_Use_Right_Window = 1 set tags = tags; set autochdirmap <silent> <F5> mz? (*) <CR> yyggpA; <ESC> 'z "creates the function prototype imap <silent> <F5> <ESC> mz? (*) <CR> yyggpA; <ESC> 'zamap <F6>: call Test () <CR> "Debug imap <F6> <ESC>: call Test () <CR> map <silent> <F7>: Grep <CR> "global search imap <silent> <F7> <ESC>: grep <CR> map <F8> I # <ESC> j0 "comment imap <F8> <ESC> I # <ESC> j0map <F9> 0Ji <CR> <ESC> "alignment level imap <F9> <ESC> 0Ji <CR> <ESC> map <F10> 0Ji <CR> <ESC>" alignment and indention imap <F10> <ESC> 0Ji <CR> <ESC> map <F11> 0Ji <CR> <ESC> XXXX <ESC> "align and reduce indentation imap <F11> <ESC> 0Ji <CR> <ESC> XXXX <ESC> function Python_Test () let mp = & makeprg let ef = & errorformat let exeFile = expand ("%: t ") setlocal makeprg = python \-u set efm = % C \ %. % #, % A \ File \ "% f \" \, \ line \ % l %. % #, % Z % [% ^ \] % \\@= % m silent make % copen let & makeprg = mp let & errorformat = efendfunctionfunction C_Test () let cmd = "! Gcc "let option ="-O2 "if search (" math \. h ")! = 0 let option. = "-lm" endif exec cmd. "%". option endif exec "!. /. Out "copenendfunctionfunction Test () exec" w "if & filetype =" c "exec" call C_Test () "elseif & filetype =" python "exec" call Python_Test () "endifendfunction

Enjoy VI Enjoy Code!

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.