"Linux" "Vim" vim Tips__linux

Source: Internet
Author: User

Global find substitution
:%s/stext/rtext/g
Like what:
:%s/text/txt/g is to replace all the text into txt. How does vim collectively indent a piece of code or vice versa?

Very simple, by V into the visual mode, select the code to indent, press > Indent code, a > Insert a tab, of course, to insert 3 tab on the input 3>

The tab width can be set in _VIMRC

Set tabstop=4 

Set shiftwidth=4

use VIM bulk annotations and bulk counter annotations

When writing code often to annotate a large section of code, a line of comments of course is the stupidest way, in vim you can do this, move to the line where you want to start the annotation, Ctrl + V go into the Visual column selection mode, move to the cursor to the last line that needs to be commented (note that if you know the line number, you can use the line number g ( g) quickly jump to the line, then press I (uppercase), enter the Insert mode, enter the annotation character, such as C++/c#/java is//, and then press ESC to return to command mode, see the miracle happened?!

What about the reverse annotation? Simpler, also CTRL + V into column selection mode, move to the cursor to select the annotation, press D,ok?! let vim automatically highlight the syntax after a new file is saved

Before using VIM, add syntax on,filetype on in VIMRC, you can automatically recognize the file when you open it, or create a suffix file with the following: E *.py, and syntax highlighting, but if you write code in an empty file and save it, This time vim does not automatically syntax highlighting, which makes me very uncomfortable. Today, I learned a technique to go to the water Wood Tsinghua Vim Edition, and add au Bufwritepost * filet detect to your VIMRC to achieve this function.

Turn tab into spaces

Add in VIMRC
Set tabstop=4
Set shiftwidth=4
Set Expandtab

If you want a different Format tab in the consolidated file, use the
: Retab
This command is very useful for solving the "indentationerror:expected an indented block":

PS: Attachment is the VIMRC file I am using

Part of this article comes from the Internet:
Http://openspirits.com/articles/tag/vim
Resources:
Tips for using the tab in VIM
Vim Find Substitution Summary

Attachment:

. VIMRC

Http://www.mangbar.com/document/5d023b211232d34601123be6c9e903ee

Other information:

Http://blog.csdn.net/easwy/category/234641.aspx?PageNumber=3

Vim uses small plugins

http://www.vim.org/scripts/script.php?script_id=1764

http://www.vim.org/

Http://www.cnblogs.com/Henrya2/archive/2009/02/21/1395591.html

Turn from: http://blog.csdn.net/xian_qiang/archive/2009/12/23/5064424.aspx
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.