How to Use vi (vim) to Program II

Source: Internet
Author: User

Previous Article http://www.cnblogs.com/amaoxiaozhu/archive/2012/03/23/2414007.html

This article is very helpful:

Http://blog.csdn.net/wooin/article/details/1858917

 

Zero, Code Completion

Extremely powerful functions, in editing mode

Ctrl + p or ctrl + n: it is a good habit to complete the word writing code.

Ctrl + x + l: Find the same row for completion similar to the copy Function

Ctrl + x + f: it is very useful to complete the path. For example, remember/usr/lib/python2.6 when I need to add the system path to the tags ~

Ctrl + x + D: You can use ctrl + p to complete the macros.

  

I. Color

Python code has been written a lot, and it gets an IDLE style. What nice looks can you recommend?

Http://www.vim.org/scripts/download_script.php? Src_id = 1, 15771

 

2. Powerful tag ctags

0. It is best to allow the local version to Exceed 5.0. Otherwise, the unrecognized option '-- format = 2' type error will be displayed in the future.

Ctags: Official Website

1. pre-process the source code directory of the tag. For example, ctags-R *. py is used here.

2. Jump to definition: ctrl +] Jump Back: ctrl + t

3. Set multiple tags paths: Just jump across your project. What should I do if I want to see the system function? Use :! Man is fine, but what should I do if I want to see python library functions?

You can edit your own vimrc directly in vi: e $ MYVIMRC, but of course you don't need to input so much. After entering MY, you can use the tab to complete it,

Set tags =./tags,/usr/lib/python2.6/tags

4. Display All tags of a keyword:

: Ts keywords used when you want to quickly find the Function Definition

 

Iii. Common plug-ins

Plugin installation steps:

1. copy the file to the corresponding folder. You can select $ HOME/. vim $ HOME/vimfiles or $ VIM/vimfiles.

2. Go to the doc folder, open vi, and run helptags. Add the help document.

3. Configure the. vimrc file as needed and use let to set some environments.

 

Common commands:

Ctrl + w window switch

Ctrl + w + o only display the current form

 

Plug-in recommendation

1. You will know if taglist has been used!

: Http://www.vim.org/scripts/script.php? Script_id = 1, 273

Common configurations:

Only the current document list is displayed. Only the List window is closed. The list tree is displayed on the right.

Let Tlist_Show_One_File = 1
Let Tlist_Exit_OnlyWindow = 1
Let Tlist_Use_Right_Window = 1

Enter the command: Tl [tab] to complete

Common commands:

X maximized/restored Tlist window

-Or zc folding

+ Or zo

= Fold all

* Open all

2. Grep thinks this should be necessary.

Download: http://www.vim.org/scripts/script.php? Script_id = 1, 311

: Grep or bind directly to the shortcut key
Map <silent> <F7>: Grep <CR> Search all in the current directory.

  

Note that the special ing in the keyboard in putty will correspond the F1-F12 to different sending content, you can select the keyboard in terminal

The Function keys and keypad correspond to Xterms to make it available after F5 :)

  

I also downloaded a fun little plug-in for matrix. vim.

Pydiction-1.2 python code completion

Nerdtree is rarely used. You can browse the directory if necessary.

Omnicppcomplete-0.41 c-class code completion

Iv. Macro recording

Powerful text editors must support all functions

P [a-z]: The next action recording is saved to the letter x.

Run a command and then run Esc and q. In this way, the previous actions are saved.

N @ [a-z]: calls a macro n times

For example, I often like to comment out the full text:

0. gg 1. qa 2. I 3. #4. Esc 5.j 6. q 7. 100 @

Of course, you can also use the method of literature and art: % s/^ /#

V. Replacement

To replace a piece of text, but do not know the start and end lines, you can enter V to enter, visual mode, to include the selected text up or down, and then execute: will appear: '<''>' style. Then, input s/old/new/g to replace all the content in the selected text.

 

This is what we use for the time being. I feel that writing code is sufficient. Paste. vimrc and update it later.

Set autoindent
Set syntax = on
Set softtabstop = 4
Filetype plugin on
Colorscheme IDLE

Let g: pydiction_location = '/root/conf/vi/complete-dict'

Let Tlist_Show_One_File = 1
Let Tlist_Exit_OnlyWindow = 1
Let Tlist_Use_Right_Window = 1

Set tags =./tags,/usr/lib/python2.6/tags
Map <silent> <F7>: Grep <CR>
Imap <silent> <F7> <ESC>: Grep <CR>

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.