Common settings of the vim Editor

Source: Internet
Author: User

1. In securecrt, when securecrt uses vim, syntax highlighting is not actually a function of securecrt, but a function of vim.

Settings: Options-> session options-> terminal-> in emulation, select ANSI or Linux or xterm for terminal. ANSI colour must be hooked.

Set options-> session options-> terminal-> simulation-> terminal: Linux, select ANSI color

2. Create. vimrc in the user directory

[Root @ localhost ~] # Vi. vimrc

3. Add the. vimrc File

Syntax on

4. Save and reconnect to ssh. Done

The following content is extended:

VI also has many personalized configurations that can be added to. vimrc for your convenience.

Below is a basic configuration

Set fenc = UTF-8 "Set Default Decoding
Set fencs = UTF-8, USC-bom, EUC-JP, gb18030, GBK, gb2312, cp936
Set nocp "or set nocompatible is used to disable the compatibility mode of VI.
Set number "display row number
Set ai "or set autoindent Vim uses automatic alignment to apply the alignment format of the current row to the next row.
Set Si "or set smartindent intelligently selects Alignment Based on the alignment format above
Set tabstop = 4 "set the tab key to 4 spaces
Set Sw = 4 "or set shiftwidth sets four spaces when the rows are staggered
Set rcursor "sets the status line at the cursor position in the lower right corner during editing.
Set incsearch "to set incremental search. This query is smart.
Set showmatch "highlight matching parentheses
Set matchtime = 5 "matching bracket highlighted time (unit: 1/10 s) set ignorecase" Case Insensitive during search
Syntax on "highlight syntax

 

"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

"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

"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 <c-o> <ESC> '<I <! -- <ESC> O <ESC> '> O -->
Autocmd filetypeJava, C, CPP, CS vmap <c-o> <ESC> '<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 the following code is available inWindowsWill report an error
"Remove the./characters.

"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

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

"General settings of the minibufexpl plug-in
Let G: minibufexplmapwindownavvim = 1
Let G: minibufexplmapwindownavarrows = 1
Let G: minibufexplmapctabswitchbufs = 1
Let G: minibufexplmodseltarget = 1

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.