The best Vim configuration file in the World (revised version)

Source: Internet
Author: User
Tags set background
The most powerful vimrc file in history, which is said to have 800 lines, is still the result of the author's simplified design. I made some minor modifications while keeping the original author's idea as much as possible. The main changes are as follows: Added compatibility with win32 systems, the original vimrc file is only compatible with linux and mac, and some shortcut keys are modified. for example, ctr-q is used by the original author to search for buffer and win32 vi is used.

The most powerful vimrc file in history, which is said to have 800 lines, is still the result of the author's simplified design.

I made some minor changes while keeping the original author's idea as much as possible. The main changes are as follows:

Added compatibility with the win32 system. The original vimrc file is only compatible with linux and mac.

Corrected some shortcut keys. for example, ctr-q is used by the original author to search for buffer. anyone who has used vim of win32 version knows that ctrl-q is used as the shortcut key for block editing, therefore, ctrl-q cannot be moved for other purposes.

With colorscheme removed, the original colorscheme is too geeky for me. I think the default colorscheme of the software should be the most suitable for most people.

The swap file is enabled because my machine configuration is too low and I often want to edit large files

Removed all python-related plug-ins, because of some path problems, and because I think vim's support for python is powerful enough (the fact is, I lack experience in writing large projects in python ).

Added support for Chinese encoding, referring to an article by Wu Yongwei

Compatible with earlier versions of vi. I have tested vim5.8.9, vim6.1, vim6.3, vim6.4, and vim7.0.

Other general and compatibility corrections

The input is removed ([{is used to automatically fill in the right brackets, which adds a lot of trouble when I modify the code.

I strongly recommend that you read this vimrc file, at least I do.

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"_
"_ |
"/|/
"_ |
"By Amix-http://amix.dk/
"
"Maintainer: Amir Salihefendic
"Version: 2.0
"Last Change: 12/08/06 13:39:28
"Fixed (win32 compatible) by: redguardtoo
"This vimrc file is tested on platforms like win32, linux, cygwin, mingw
"And vim7.0, vim6.4, vim6.1, vim5.8.9 by redguardtoo
"
"Tip:
"If you find anything that you can't understand than do this:
"Help keyword OR helpgrep keyword
"Example:
"Go into command-line mode and type helpgrep nocompatible, ie.
": Helpgrep nocompatible
"Then press C to see the results, or: botrightcw
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> General
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Get out of VI's compatible mode ..
Set nocompatible

Function! MySys ()
If has ("win32 ")
Return "win32"
Elseif has ("unix ")
Return "unix"
Else
Return "mac"
Endif
Endfunction
"Set shell to be bash
If MySys () = "unix" | MySys () = "mac"
Set shell = bash
Else
"I have to run win32 python without cygwin
"Set shell = E: cygwininsh
Endif

"Sets how many lines of history VIM har to remember
Set history = 400

"Enable filetype plugin
Filetype on
If has ("eval") & amp; v: version & gt; = 600
Filetype plugin on
Filetype indent on
Endif

"Set to auto read when a file is changed from the outside
If exists ("& autoread ")
Set autoread
Endif

"Have the mouse enabled all the time:
Set mouse =

"Set mapleader
Let mapleader = ","
Let g: mapleader = ","

"Fast saving
Nmap W: w!

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Colors and Font
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Enable syntax hl
If MySys () = "unix"
If v: version: <600
If filereadable (expand ("$ VIM/syntax. vim "))
Syntax on
Endif
Else
Syntax on
Endif
Else
Syntax on
Endif

"Internationalization
"I only work in Win2k Chinese version
If has ("multi_byte ")
Set termencoding = chinese
Set encoding = UTF-8
Set fileencodings = ucs-bom, UTF-8, chinese
Endif

"If you use vim in tty,
"'Uxterm-cjk 'or putty with option 'treat CJK ambiguous charactersas wide' on
If exists ("& ambiwidth ")
Set ambiwidth = double
Endif

If has ("gui_running ")
Set guioptions-= m
Set guioptions-= T
Set guioptions-= l
Set guioptions-= L
Set guioptions-= r
Set guioptions-= R

If MySys () = "win32"
"Start gvim maximized
If has ("autocmd ")
Au GUIEnter * simalt ~ X
Endif
Endif
"Let psc_style = 'cool'
"Colorscheme ps_color
"Colorscheme default
Else
"Set background = dark
"Colorscheme default
Endif

"Some nice mapping to switch syntax (useful if one mixesdifferent versions in one file)
Map 1: set syntax = cheetah
Map 2: set syntax = xhtml
Map 3: set syntax = python
Map 4: set ft = javascript
Map $: Syntax sync fromstart

"Highlight current
If has ("gui_running ")
If exists ("& cursorline ")
Set cursorline
Endif
Endif

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Fileformat
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Favorite filetype
Set ffs = unix, dos, mac

Nmap Fd: se ff = dos
Nmap Fu: se ff = unix

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> VIM userinterface
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Set 7 lines to the curors-when moving vertical ..
Set so = 7

"Turn on WiLd menu
Set wildmenu

"Always show current position
Set ruler

"The commandbar is 2 high
Set bytes height = 2

"Show line number
Set nu

"Do not redraw, when running macros... lazyredraw
Set lz

"Change buffer-without saving
Set hid

"Set backspace
Set backspace = eol, start, indent

"Bbackspace and cursor keys wrap
Set whichwrap + = <,>, h, l

"Ignore case when searching
"Set ignorecase
Set incsearch

"Set magic on
Set magic

"No sound on errors.
Set noerrorbells
Set novisualbell
Set t_vb =

"Show matching bracet
Set showmatch

"How many tenths of a second to blink
Set mat = 4

"Highlight search thing
Set hlsearch

""""""""""""""""""""""""""""""
"=> Statusline
""""""""""""""""""""""""""""""
"Format the statusline
"Nice statusbar
Set laststatus = 2
Set statusline =
Set statusline + = % 2 * %-3.3n % 0 */"buffer number
Set statusline + = % f/"file name
Set statusline + = % h % 1 * % m % r % w % 0 * "flag
Set statusline + = [
If v: version> = 600
Set statusline + =%{ strlen (& ft )? & Ft: 'none'}, "filetype
Set statusline + =%{ & encoding}, "encoding
Endif
Set statusline + =%{ & fileformat}] "file format
If filereadable (expand ("$ VIM/vimfiles/plugin/vimbuddy. vim "))
Set statusline + =/% {VimBuddy ()} "vim buddy
Endif
Set statusline + = % = "right align
Set statusline + = % 2 * 0x %-8B/"current char
Set statusline + = %-14. (% l, % c % V %)/% <% P "offset

"Special statusbar for special window
If has ("autocmd ")
Au FileType qf
/If & buftype = "quickfix" |
/Setlocal statusline = % 2 * %-3.3n % 0 * |
/Setlocal statusline + = // [Compiler/Messages/] |
/Setlocal statusline + = % 2 */% <% P |
/Endif

Fun! Fixminibufpolicertitle ()
If "-MiniBufExplorer-" = bufname ("% ")
Setlocal statusline = % 2 * %-3.3n % 0 *
Setlocal statusline + =/[Buffers/]
Setlocal statusline + = % 2 */% <% P
Endif
Endfun

If v: version> = 600
Au BufWinEnter *
/Let oldwinnr = winnr () |
/Windo call FixMiniBufExplorerTitle () |
/Exec oldwinnr. "wincmd w"
Endif
Endif

"Nice window title
If has ('title') & (has ('gui _ running') | & title)
Set titlestring =
Set titlestring + = % f/"file name
Set titlestring + = % h % m % r % w "flag
Set titlestring + =/-/% {v: progname} "program name
Endif

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Moving around and tab
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Map space to/and c-space?
Map /

"Smart way to move btw. window
Map J
Map K
Map H
Map L

"Actually, the tab does not switch buffers, but my arrow
"Bclose function ca be found in" Buffer related "section
Map Bd: Bclose
Map Bd
"Use the arrows to something usefull
Map : Bn
Map : Bp

"Tab configuration
Map Tn: tabnew %
Map Tc: tabclose
Map Tm: tabmove

If v: version> = 700
Set switchbuf = usetab
Endif

If exists ("& showtabline ")
Set bandwidth = 2
Endif

"Moving fast to front, back and 2 sides ;)
Imap $
Imap 0i
Imap $
Imap 0i

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> General Autocommand
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Switch to current dir
Map Cd: cd %: p: h

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Parenthesis/bracket expanding
"""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""
Vnoremap $1 '>) '
")
Vnoremap $2 '> A] '
Vnoremap $3 '>} '
Vnoremap $ '>" '
Vnoremap $ q '>' '
Vnoremap $ w '>" '
Imap La
Imap Ha

"Map auto complete (,",',[
"Http://www.vim.org/tips/tip.php? Tip_id = 1, 153
"

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> General Abbrev
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Comment for C like language
If has ("autocmd ")
Au BufNewFile, BufRead *. js, *. htc, *. c, *. tmpl, *. css ino $ c /** **/ O
Endif

"My information
Ia xdate = Strftime ("% d/% m/% y % H: % M: % S ")
"Iab xname Amir Salihefendic

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Editing mappings etc.
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Remap VIM 0
Map 0 ^

"Move a line of text using control
Nmap Mz: m + 'Z
Nmap Mz: M-2 'Z
Vmap : M'> + ' Mzgv 'Yo' z
Vmap : M' <-2 '> My'

If MySys () = "mac"
Nmap
Nmap
Vmap
Vmap
Endif

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Command-line config
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
Func! Cwd ()
Let cwd = getcwd ()
Return "e". cwd
Endfunc

Func! DeleteTillSlash ()
Let g: cmd = getcmdline ()
If MySys () = "unix" | MySys () = "mac"
Let g: cmd_edited = substitute (g: cmd, "(. * [/]). *", "", "")
Else
Let g: cmd_edited = substitute (g: cmd, "(. * [/]). *", "", "")
Endif
If g: cmd = g: pai_edited
If MySys () = "unix" | MySys () = "mac"
Let g: cmd_edited = substitute (g: cmd, "(. * [/]). */", "", "")
Else
Let g: cmd_edited = substitute (g: cmd, "(. * [/]). * [/]", "", "")
Endif
Endif
Return g: pai_edited
Endfunc

Func! CurrentFileDir (cmd)
Return a: cmd. "". expand ("%: p: h ")."/"
Endfunc

"Cno $ q EDeleteTillSlash ()
"Cno $ c e ECurrentFileDir ("e ")
"Cno $ tc ECurrentFileDir ("tabnew ")
Cno $ th tabnew ~ /
Cno $ td tabnew ~ /Desktop/

"Bash like
Cno
Cno
Cno

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Buffer realted
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Fast open a buffer by search for a name
"Map : Sb

"Open a dummy buffer for paste
Map Q: e ~ /Buffer

"Restore cursor to file position in previous editing session
Set viminfo = '10, "100,: 20, %, n ~ /. Viminfo

"Buffer-reverse everything ...:)
Map GgVGg?

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Files and backup
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Turn backup off
Set nobackup
Set nowb
"Set noswapfile

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Folding
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Enable folding, I find it very useful
If exists ("& foldenable ")
Set fen
Endif

If exists ("& foldlevel ")
Set fdl = 0
Endif

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Text option
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Python script
"Set expandtab
Set shiftwidth = 2
Set softtabstop = 2
Set tabstop = 2
Set backspace = 2
Set smarttab
Set lbr
"Set tw = 500

""""""""""""""""""""""""""""""
"=> Indent
""""""""""""""""""""""""""""""
"Auto indent
Set ai

"Smart indet
Set si

"C-style indenting
Set cindent

"Wrap line
Set wrap

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Spell checking
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
Map Sn]
Map Sp [
Map Sa zg
Map S? Z =

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Plugin configuration
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
""""""""""""""""""""""""""""""
"=> Yank Ring
""""""""""""""""""""""""""""""
Map Y: YRShow

""""""""""""""""""""""""""""""
"=> File explorer
""""""""""""""""""""""""""""""
"Split vertically
Let g: explVertical = 1

"Window size
Let g: explWinSize = 35

Let g: explSplitLeft = 1
Let g: explSplitBelow = 1

"Hide some file
Letg: explHideFiles = '^.,. *. class $,. *. swp $,. *. pyc $,. *. swo $,. DS_Store $'

"Hide the help thing ..
Let g: explDetailedHelp = 0

""""""""""""""""""""""""""""""
"=> Minibuffer
""""""""""""""""""""""""""""""
Let g: miniBufExplModSelTarget = 1
Let g: minibufpolicermorethanone = 0
Let g: miniBufExplModSelTarget = 0
Let g: miniBufExplUseSingleClick = 1
Let g: miniBufExplMapWindowNavVim = 1
Let g: miniBufExplVSplit = 25
Let g: miniBufExplSplitBelow = 1

"WindowZ
Map : WMToggle

Let g: bufpolicersortby = "name"

""""""""""""""""""""""""""""""
"=> Tag list (ctags)-not used
""""""""""""""""""""""""""""""
"Let Tlist_Ctags_Cmd ="/sw/bin/ctags-exuberant"
"Let Tlist_Sort_Type =" name"
"Let Tlist_Show_Menu = 1
"Map T: Tlist
Map : Tlist

""""""""""""""""""""""""""""""
"=> LaTeX Suite thing
""""""""""""""""""""""""""""""
"Set grepprg = grep-r-s-n
Let g: Tex_DefaultTargetFormat = "pdf"
Let g: Tex_ViewRule_pdf = 'xpdf'

If has ("autocmd ")
"Binding
Au BufRead *. tex map : W! : Silent! Call Tex_RunLaTeX ()

"Auto complete some things ;)
Au BufRead *. tex ino $ I indent
Au BufRead *. tex ino $ * Cdot
Au BufRead *. tex ino $ I item
Au BufRead *. tex ino $ M [ ] O
Endif

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Filetype generic
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"=> Todo
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""
"Au BufNewFile, BufRead *. todo so ~ /Vim_local/syntax/amido. vim

""""""""""""""""""""""""""""""
"=> VIM
""""""""""""""""""""""""""""""
If has ("autocmd") & v: version> 600
Au BufRead, BufNew *. vim map : W! : Source %
Endif

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

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.