Vim configuration and vim auto-completion code (code prompt) plug-in sharing

Source: Internet
Author: User
Modify the. vimrc file under your user directory. There is a "." In ubuntu, it indicates a hidden file. Then, put the configuration content in the file. I. find a plug-in: AutoComplPop. Download the latest http://www.vim.org/scripts/script.php for this tool from the URL below? Script_id

Modify the. vimrc file under your user directory. There is a "." In ubuntu, it indicates a hidden file.

Then, put the configuration content in the file.

I. code prompts

Find a plug-in: AutoComplPop. Download the latest version of the tool from the URL below
Http://www.vim.org/scripts/script.php? Script_id = 1, 1879
Put the decompressed files (autoload, doc, and plugin) ~ /. Vim/under the folder

Restart and OK.

Ps: vim has a shortcut key that can be used to complete the code C-n (Ctrl + n)

II. Auto-generated parentheses

Add the following content to the. vimrc file:

"Provides automatic indentation for C programs
Set smartindent
"Code completion
Set completeopt = preview, menu
"Auto-completion
: Inoremap (() I
: Inoremap) = ClosePair (')')
: Inoremap {{ } O
: Inoremap} = ClosePair ('}')
: Inoremap [[] I
: Inoremap] = ClosePair (']')
: Inoremap """ I
": Inoremap" = ClosePair ('"')
: Inoremap ''' I
": Inoremap' = ClosePair ('\'')
Function! ClosePair (char)
If getline ('.') [col ('.')-1] = a: char
Return "\ "
Else
Return a: char
Endif
Endfunction
Filetype plugin indent on
"Enable the file type check. you can use this sentence to complete it intelligently.
Set completeopt = longest, menu

III. content of my vim configuration file (. vimrc)

Basic configuration:

"Syntax highlighting
Set syntax = on
"Confirmation pops up when processing unsaved or read-only files
Set confirm
"Auto Indent
Set autoindent
Set cindent
"Tab key width
Set tabstop = 4
"Unified indent to 4
Set softtabstop = 4
Set shiftwidth = 4
"Do not use spaces instead of tabs
Set noexpandtab
"Use a tab at the beginning of a row and segment
Set smarttab
"Display row number
Set number
"Number of historical records
Set history = 1000
"Do not generate temporary files
Set nobackup
Set noswapfile
"Search for highlighted characters by character
Set hlsearch
Set incsearch
"Intra-row replacement
Set gdefault
"Encoding Settings
Set enc = UTF-8
Set fencs = UTF-8, ucs-bom, shift-jis, gb18030, gbk, gb2312, cp936
"Language Settings
Set langmenu = zh_CN.UTF-8
Set helplang = cn
"Content displayed in my status line (including file type and decoding)
Set statusline = % F % m % r % h % w \ [FORMAT = % {& ff}] \ [TYPE = % Y] \ [POS = % l, % v] [% p %] \%{ strftime (\ "% d/% m/% y \-\ % H: % M \")}
"Set statusline = [% F] % y % r % m % * % = [Line: % l/% L, Column: % c] [% p %]
"Always show status line
Set laststatus = 2
"The status line at the cursor position is displayed in the lower right corner during editing.
Set ruler
"The height of the command line (under the status line). The default value is 1. here is 2.
Set bytes height = 2
"File type detection
Filetype on
"Load file type plug-in
Filetype plugin on
"Load indent files for a specific file type
Filetype indent on
"Save Global variables
Set viminfo + =!
"Do not separate words with the following symbols by line breaks
Set iskeyword + =_, $, @, % ,#,-
"Number of pixel rows inserted between characters
Set linespace = 0
"The command line in enhanced mode automatically completes the operation
Set wildmenu
"Enable backspace to process indent, eol, start, and so on.
Set backspace = 2
"Allow backspace and cursor keys to span row boundaries
Set whichwrap + = <,>, h, l
"You can use the mouse anywhere in the buffer (similar to double-click the mouse in the workspace in office to locate the location)
Set mouse =
Set selection = exclusive
Set selectmode = mouse, key
"The commands command tells us which row of the file has been changed.
Set report = 0
"The prompt for assistance to children in Somalia is not displayed at startup.
Set shortmess = atI
"White space is displayed between split windows for ease of reading
Set fillchars = vert: \, stl: \, stlnc :\
"Highlight matching brackets
Set showmatch
"Matching the time when brackets are highlighted (unit: 10 seconds)
Set matchtime = 5
"Move the cursor to the top and bottom of the buffer to keep the distance between three rows
Set scroloff = 3

The following is the supplemental auto-completion and plug-in configuration. In fact, the basic operations above are almost the same.

"Provides automatic indentation for C programs
Set smartindent
"Code completion
Set completeopt = preview, menu
"Auto-completion
: Inoremap (() I
: Inoremap) = ClosePair (')')
: Inoremap {{ } O
: Inoremap} = ClosePair ('}')
: Inoremap [[] I
: Inoremap] = ClosePair (']')
: Inoremap """ I
": Inoremap" = ClosePair ('"')
: Inoremap ''' I
": Inoremap' = ClosePair ('\'')
Function! ClosePair (char)
If getline ('.') [col ('.')-1] = a: char
Return "\ "
Else
Return a: char
Endif
Endfunction
Filetype plugin indent on
"Enable the file type check. you can use this sentence to complete it intelligently.
Set completeopt = longest, menu
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.