Vim beginner configuration notes vimrc

Source: Internet
Author: User
(After vimtuor, continue to take the learning notes. Next, follow the help document to complete the exercises and integrate GDB)

Vimrc configurations of Vim are mainly used in C/C ++.
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""

"Chinese
Set helplang = Cn

UTF-8 encoding
Set encoding = UTF-8

"Syntax highlighting
Syntax enable
Syntax on
Colorscheme desert

"Set the (soft) tab width to 4:
Set tabstop = 4
Set softtabstop = 4

"Set the number of indented spaces to 4.
Set shiftwidth = 4

"Set automatic indent: the indent value of each line is equal to that of the previous line. Use noautoindent to cancel the settings:
Set autoindent

"Set the automatic indent mode in C/C ++:
Set cindent

"Set the specific indent mode of C/C ++ language (taking my windows style as an example ):
Set cinoptions = {s, T0, N-2, P2s, (03 S, =. 5 S,> 1 s, = 1 s,: 1 s

"To display the line number of the text on the left, use the following statement:
Set nu

"If the following statements are not found, add them:
If & term = "xterm"
Set t_co = 8
Set t_sb = ^ [4% DM
Set t_sf = ^ [3% DM
Endif

"Taglist ctins ctags INS: taglist
Let tlist_show_one_file = 1
Let tlist_exit_onlywindow = 1

"File browser and window manager -- plug-in: winmanager
Let G: winmanagerwindowlayout = 'fileexplorer | taglist'
Nmap wm: wmtoggle <CR>

"Tags
"Set tags =./tags

"Whether to use the quickfix window to display csfix results
Set cscopequickfix = s-, C-, D-, I-, T-, e-

"Csing cscope keyboard
NMAP <c-_> S: CS find S <C-R> = expand ("<cword>") <CR>
NMAP <c-_> G: CS find G <C-R> = expand ("<cword>") <CR>
NMAP <c-_> C: CS find C <C-R> = expand ("<cword>") <CR>
NMAP <c-_> T: CS find t <C-R> = expand ("<cword>") <CR>
NMAP <c-_> E: CS find e <C-R> = expand ("<cword>") <CR>
NMAP <c-_> F: CS find F <C-R> = expand ("<cfile>") <CR>
NMAP <c-_> I: CS find I <C-R> = expand ("<cfile>") <CR>
NMAP <c-_> D: CS find d <C-R> = expand ("<cword>") <CR>

"Quick browser and operation buffer -- plug-in: minibufexplorer
"The following two functions must be found in ~ /. Added in vimrc:
Let G: minibufexplmapctabswitchbufs = 1 "<c-tab> switch to each buffer in the forward loop, and open
"<C-S-tab> switches back to each buffer and opens
"If ~ /. The following sentence is set in vimrc:
Let G: minibufexplmapwindownavvim = 1 ", you can use <C-H, J, K, L> to switch to the upper and lower left windows, just like:
"C-W, h j k l to" Left, bottom, top, right "switch window.
"In ~ /. Set in vimrc:
Let G: minibufexplmapwindownavarrows = 1 "is to use the <c-arrow key> to switch to the upper, lower, and left windows.

"Switch between C/H files -- plug-in:
Nnoremap <silent> <F12>: A <CR> "means to open the c \ H file in a new buffer when pressing F12,

"Find -- plug-in: grep in the project
Nnoremap <silent> <F3>: grep <CR> "Press F3

"C smart completion
Filetype plugin indent on "open the file type check. You can use this sentence to complete it intelligently.
Set completeopt = longest, menu "turn off the smart full-time preview window

"Accelerate your completion-plug-in: supertab
Let G: supertabretaincompletiontype = 2 "sets the default completion mode after you press <tab>
Let G: supertabdefacomplecompletiontype = "<C-X> <C-O>" "2-remember the last Completion mode until you Press ESC to exit insert mode

"Disabled the VI compatibility mode and allowed file type detection plug-insOmnicppcomplete:
"C ++ complete the CTAG command ctags-r -- C ++-kinds = + p -- fields = + IAS -- extra = + q SRC
Set nocp
Filetype plugin on

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""
More dazzling syntax highlights:
You may find that many things are not highlighted, such as operator numbers, brackets, function names, and custom types, my operator numbers and function names are highlighted ^ _ ^. Do you want to know why? Wow, haha... Let me teach you...

Master
The idea is to create a new syntax file, define what you want to highlight in the file, highlight what you want to highlight, and use Vim to be so confident.
The so-called syntax file is a script used by VIM to highlight various source files. Vim relies on the description of this script to display different colors for different texts in the file,
For example, the C language syntax file is placed in a path similar to this:
/Usr/share/Vim/vim64/syntax/C. Vim
Syntax files in other languages can also be found in this path. You may not be in this path. Regardless of it, create a syntax file in your own home and create an empty file:
~ /. Vim/syntax/C. Vim
Add

"============================================== ========================
"Highlight all function
"============================================== ========================
SYN Match Cfunction "\ <[A-Za-Z _] [a-zA-Z_0-9] * \> [^ ()] *) (" Me = E-2
SYN Match Cfunction "\ <[A-Za-Z _] [a-zA-Z_0-9] * \> \ s *(" Me = E-1
Hi Cfunction Gui = None Guifg = # B5a1ff

"============================================== ========================
"Highlight all math Operator
"============================================== ========================
"C math Operators
SYN Match Cmathoperator Display "[-+ \ */% =]"
"C pointer Operators
SYN Match Cpointeroperator Display "-> \ | \."
"C logical operators-Boolean results
SYN Match Clogicaloperator Display "[! <>] = \ ="
SYN Match Clogicaloperator Display "="
"C bit Operators
SYN Match Cbinaryoperator Display "\ (\|\|\^\|<\|>>\) =\="
SYN Match Cbinaryoperator Display "\~ "
SYN Match Cbinaryoperatorerror Display "\~ ="
"More C logical operators-highlight in preference to binary
SYN Match Clogicaloperator Display "& \ |"
SYN Match Clogicaloperatorerror Display "\ (& \ | \) ="

"Math Operator
Hi Cmathoperator Guifg = #3effe2
Hi Cpointeroperator Guifg = #3effe2
Hi Clogicaloperator Guifg = #3effe2
Hi Cbinaryoperator Guifg = #3effe2
Hi Cbinaryoperatorerror Guifg = #3effe2
Hi Clogicaloperator Guifg = #3effe2
Hi Clogicaloperatorerror Guifg = #3effe2

Open your c file and see if it is much brighter. there is also a press box to tell you, if you add a type or structure, how to make it highlighted like "int", "Void? Next, in the above file ~ Add the following stuff to/. Vim/syntax/C. VIM:

"============================================== ========================
"My own datatype
"============================================== ========================
SYN KeywordCtype my_type_1 my_type_2 my_type_3

In this way, my_type_1, my_type_2, and my_type_3 of your own type can be highlighted like "int". The disadvantage is that you need to manually add a new type here.

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""
Several useful commands

Vnew vertical open new port

<C-W-W> switch window

: Helptags ~ /. Vim/DOC import new document

Split horizontal opening window

> Touch creates a document.

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""" """""

Ctags-r -- C ++-kinds = + p -- fields = + IAS -- extra = + q SRC (SRC isCodeDirectory)
When completing the C ++ file, the omnicppcomplete plug-in needs to include additional C ++ information in the Tag file. Therefore, the ctags command above is different from the one we used previously, it generates additional information for the c ++ language. The meanings of the preceding options are as follows:

-- C ++-kinds = + P: add the function prototype label to the C ++ file.
-- Fields = + IAS: Add Inheritance Information (I), access control information (a) of Class Members, and function fingerprint (s) to the Tag file)
-- Extra = + Q: Add a class modifier to the tag. Note: If this option is not available, the class members cannot be supplemented.

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""
When using the highlighted bookmarks-plug-in: When visualmark is used, the error e197 is always reported, and the language en_us cannot be set.
Read help Google for a long time
Finally, enter the plug-in source code to see a piece of comment "" set the language to English "for the set language"
Quickly $ locale-a put the following code
Exec ": Lan mes en_us" changed to Exec ": Lan mes en_us.utf8.

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""'
"""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""
It seems that from win, we will gradually change our habits. in Linux, we have the opportunity to look at the source code, so that is one of the charm of open source? HH ~

Now, Windows XP Ubuntu dual-system Ubuntu vbox is installed with XP SP3. After this, it will go back to win once to solve the problem of mounting failure. All the other time is in Ubuntu. I really want Internet Explorer, And I want QQ to play the game, so I want vbox. (Ies4linux is installed, but the flash is the same as the stars on the day. It cannot be changed to a pair of _ ^ ~)

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.