Configure VIM in Ubuntu

Source: Internet
Author: User
Tags eol
In Linux or windows, modify the vim configuration file as much as possible. vimrc (_ vimrc in win) in Ubuntu, use sudoapt-getinstallvim-full to update vim to the full version. Step 2: create a file in the current user's home directory. the content of vimrc is as follows: """""""""""""""""""""""""""""""""""""""" """""""""""""""""""

In either Linux or windows, modify the vim configuration file and try to modify the. vimrc (in win, _ vimrc) in your main directory)
Use sudo apt-get install vim-full in Ubuntu to update vim to the full version.
Step 2: create a file. vimrc in the current user's home directory. The content is as follows:


"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"General settings
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Set Default Decoding
Set fenc = UTF-8
Set fencs = UTF-8, usc-bom, euc-jp, gb18030, gbk, gb2312, cp936

"Do not use the vi keyboard mode, but vim's own
Set nocompatible

"Number of lines to be recorded in the history file
Set history = 100

"Confirmation pops up when processing unsaved or read-only files
Set confirm

"Share clipboard with windows
Set clipboard + = unnamed

"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 + =_, $, @, % ,#,-

"Syntax highlighting
Syntax on

"Highlight characters, so it is not limited to 100 Columns
: Highlight OverLength ctermbg = red ctermfg = white guibg = red guifg = white
: Match OverLength '\ % 101 v .*'

"Status line color
Highlight StatusLine guifg = SlateBlue guibg = Yellow
Highlight StatusLineNC guifg = Gray guibg = White

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"File Settings
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Do Not Back Up Files (choose as needed)
Set nobackup

"Do not generate a swap file. Hide it when the buffer is discarded.
Setlocal noswapfile
Set bufhidden = hide

"Number of pixel rows inserted between characters
Set linespace = 0

"The command line in enhanced mode automatically completes the operation
Set wildmenu

"Display the row number and column number at the cursor position on the Status line
Set ruler
Set rulerformat = % 20 (% 2 * % <% f % = \ % m % r \ % 3l \ % c \ % p %)

"The height of the command line (under the Status line). The default value is 1. Here is 2.
Set bytes Height = 2

"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

"White space is displayed between Split windows for ease of reading
Set fillchars = vert: \, stl: \, stlnc :\

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Search and match
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Highlight matching brackets
Set showmatch

"Matching the time when brackets are highlighted (unit: 10 seconds)
Set matchtime = 5

"Case Insensitive during search
Set ignorecase

"Do not highlight the searched sentence (phrases)
Set nohlsearch

"When searching, the entered words are highlighted by character (similar to firefox search)
Set incsearch

"Input: what should the set list command display?
Set listchars = tab: \ | \, trail:., extends:>, precedes: <, eol

"Move the cursor to the top and bottom of the buffer to keep the distance between three rows
Set scroloff = 3

"Do not flash
Set novisualbell

"Content displayed in my status line (including file type and decoding)
Set statusline = % F % m % r % h % w \ [POS = % l, % v] [% p %] \%{ strftime (\ "% d/% m/% y \-\ % H: % M \")}

"Always show status line
Set laststatus = 2

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Text format and Layout
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Automatic formatting
Set formatoptions = tcrqn

"Inherits the indentation of the previous line, especially for multiline comments.
Set autoindent

"Provides automatic indentation for C Programs
Set smartindent

"Use C-style indent
"Set cindent

"Tab is 4, unified indent is 4
Set tabstop = 4
Set softtabstop = 4
Set shiftwidth = 4

"Use spaces to replace tabs
Set expandtab

"Do not wrap
Set nowrap

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"CTags settings
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Sort by name
Let Tlist_Sort_Type = "name"

"Display window on the right
Let Tlist_Use_Right_Window = 1

"Compression mode
Let Tlist_Compart_Format = 1

"If there is only one buffer, the kill window also kill the buffer.
Let Tlist_Exist_OnlyWindow = 1

"Do not close the tags of other files
Let Tlist_File_Fold_Auto_Close = 0

"Do not show the folding tree
Let Tlist_Enable_Fold_Column = 0

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Autocommands
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"The row number is displayed only when the following file types are detected. Normal text files are not displayed.

If has ("autocmd ")
Autocmd FileType xml, html, c, cs, java, perl, shell, bash, cpp, python, vim, php, ruby set number
Autocmd FileType xml, html vmap ' O '> O -->
Autocmd FileType java, c, cpp, cs vmap ' '> O */
Autocmd FileType html, text, php, vim, c, java, xml, bash, shell, perl, python setlocal textwidth = 100
Autocmd Filetype html, xml, xsl source $ VIMRUNTIME/plugin/closetag. vim
Autocmd BufReadPost *
\ If line ("'\" ")> 0 & line ("' \ "") <= line ("$") |
\ Exe "normal G' \" "|
\ Endif
Endif "has (" autocmd ")

"F5 compiles and runs C Programs, F6 compiles and runs C ++ programs
"Please note that an error will be reported when the following code is used in windows.
"Remove the./characters.

"C compilation and running
Map : Call CompileRunGcc ()
Func! CompileRunGcc ()
Exec "w"
Exec "! Gcc %-o % <"
Exec "! ./% <"
Endfunc

"C ++ compilation and running
Map : Call CompileRunGpp ()
Func! CompileRunGpp ()
Exec "w"
Exec "! G ++ %-o % <"
Exec "! ./% <"
Endfunc

"The. NFO file can be beautifully displayed.
Set encoding = UTF-8
Function! SetFileEncodings (encodings)
Let B: myfileencodingsbk = & fileencodings
Let & fileencodings = a: encodings
Endfunction
Function! RestoreFileEncodings ()
Let & fileencodings = B: myfileencodingsbk
Unlet B: myfileencodingsbk
Endfunction

Au BufReadPre *. nfo call SetFileEncodings ('cp437') | set ambiwidth = single au BufReadPost *. nfo call RestoreFileEncodings ()

"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 @ = (Foldclosed (line ('.') <0 )? 'Zc': 'Z ')

"General settings of the minibufexpl plug-in
Let g: miniBufExplMapWindowNavVim = 1
Let g: miniBufExplMapWindowNavArrows = 1
Let g: miniBufExplMapCTabSwitchBufs = 1
Let g: miniBufExplModSelTarget = 1

Note: This is a popular. vimrc version.


After the two steps, VIM has been configured. Open it and check the effect. ^_^

After following the two steps above, we can get it done! Install vim-full before configuring it! You can use F5 and F6 for compilation!

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.