Vim personalized settings in Ubuntu

Source: Internet
Author: User
Tags set background

When you use Vim to edit a terminal, by default, the editing interface does not display line numbers, syntax High Brightness Display, smart indentation, and other functions.

To better work in Vim, You need to manually set the configuration file :~ /. Vimrc. Or/etc/Vim/vimrc. Local. (~ Represents the current user directory)

Set nu/display row number
Set nocp/remove the annoying VI consistency mode to avoid bugs and limitations in earlier versions
Set Ru/shows the status line at the cursor position in the lower right corner during editing
Set HLS/search highlighted by character
Set is/Dynamically match the keyword to be searched during search
Syntax on/syntax High Brightness Display
Set Sw = 4/"set the tab key to 4 spaces in the first line,
Set Ts = 4/set SM the second row is set to use four spaces when the rows are staggered. Set tabstop = 4 set shiftwidth = 4
Set CIN/Set automatic indentation in C format
Set guifont = courier \ new \ 10/

Set showmatch/set the matching mode, similar to the right brace that will match when a left brace is input.

Of course, the above is for reference only! For other settings, refer:

 

"Do not use the VI keyboard mode,VimYour own
Set nocompatible

"Syntax highlighting
Set syntax = on

"Remove the input error prompt sound
Set noeb

"Not saved during processing or read-onlyFileConfirmation is displayed.
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

"Black is used for background
Set background = dark

"Display row number
Set number

"Number of historical records
Set history = 1000

"Do not generate temporary files
Set nobackup
Set noswapfile

"Case-insensitive search
Set ignorecase

"Search for highlighted characters by character
Set hlsearch
Set incsearch

"Intra-row replacement
Set gdefault

"EncodingSet
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        

"CommandThe height of the row (under the Status row). 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

"Provides automatic indentation for C Programs
Set smartindent

"C compilation and running
Map <F5>: Call compilerungcc () <CR>
Func! Compilerungcc ()
Exec "W"
Exec "! GCC %-o % <"
Exec "! ./% <"
Endfunc

"C ++ compilation and running
Map <F6>: Call compilerungpp () <CR>
Func! Compilerungpp ()
Exec "W"
Exec "! G ++ %-o % <"
Exec "! ./% <"
Endfunc

"Highlight common TXT files (txt. Vim script is required)
AU bufread, bufnewfile *Setfiletype txt

"Use the Space key to switch and collapse
Set foldenable
Set foldmethod = manual
Nnoremap <space >@= (foldclosed (line ('.') <0 )? 'Zc': 'Z') <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.