In ubuntu12.04, the vim basic configuration automatically includes line breaks and brackets to automatically display line numbers.

Source: Internet
Author: User

Copy the following code ~ /. Vimrc (~ Is your main directory. If ~ /. Vimrc, touch one to be in ~ Touch. vimrc,

. Vimrc is a hidden file, in ~ Enter LS-a to check whether the file exists ):

Set nocompatible
Set number
Set autoindent
Set smartindent
Set showmatch
Set ruler
Set incsearch
Set tabstop = 4
Set shiftwidth = 4
Set softtabstop = 4
Set cindent
Set nobackup
Set clipboard + = unnamed

Inoremap () <ESC> I
Inoremap [[] <ESC> I
Inoremap {<CR >}< ESC> O
Autocmd syntax HTML, VIM inoremap <lt> <ESC> I | inoremap> <c-r> = closepair ('>') <CR>
Inoremap) <c-r> = closepair (') <CR>
Inoremap] <c-r> = closepair (']') <CR>
Inoremap} <c-r >= closebracket () <CR>
Inoremap "<c-r> = quotedelim ('"') <CR>
Inoremap' <c-r> = quotedelim ("'") <CR>

Function closepair (char)
If Getline ('.') [col ('.')-1] = A: Char
Return "\ <right>"
Else
Return A: Char
Endif
ENDF

Function closebracket ()
If match (Getline (line ('.') + 1), '\ s *}') <0
Return "\ <CR> }"
Else
Return "\ <ESC> j0f}"
Endif
ENDF

Function quotedelim (char)
Let line = Getline ('.')
Let Col = COL ('.')
If line [col-2] = "\\"
"Inserting a quoted quotation mark into the string
Return A: Char
Elseif line [col-1] = A: Char
"Escaping out of the string
Return "\ <right>"
Else
"Starting a string
Return A: Char. A: Char. "\ <ESC> I"
Endif
ENDF

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.