vimrc


vimrc

  文件取自网页:https://vim.fandom.com/wiki/Example_vimrc

  1 " URL: http://vim.wikia.com/wiki/Example_vimrc
  2 " Authors: http://vim.wikia.com/wiki/Vim_on_Freenode
  3 " Description: A minimal, but feature rich, example .vimrc. If you are a
  4 "              newbie, basing your first .vimrc on this file is a good choice.
  5 "              If you're a more advanced user, building your own .vimrc based
  6 "              on this file is still a good idea.
  7 
  8 "------------------------------------------------------------
  9 " Features {{{1
 10 "
 11 " These options and commands enable some very useful features in Vim, that
 12 " no user should have to live without.
 13 
 14 " Set 'nocompatible' to ward off unexpected things that your distro might
 15 " have made, as well as sanely reset options when re-sourcing .vimrc
 16 set nocompatible
 17 
 18 " Attempt to determine the type of a file based on its name and possibly its
 19 " contents. Use this to allow intelligent auto-indenting for each filetype,
 20 " and for plugins that are filetype specific.
 21 if has('filetype')
 22   filetype indent plugin on
 23 endif
 24 
 25 " Enable syntax highlighting
 26 if has('syntax')
 27   syntax on
 28 endif
 29 
 30 "------------------------------------------------------------
 31 " Must have options {{{1
 32 "
 33 " These are highly recommended options.
 34 
 35 " Vim with default settings does not allow easy switching between multiple files
 36 " in the same editor window. Users can use multiple split windows or multiple
 37 " tab pages to edit multiple files, but it is still best to enable an option to
 38 " allow easier switching between files.
 39 "
 40 " One such option is the 'hidden' option, which allows you to re-use the same
 41 " window and switch from an unsaved buffer without saving it first. Also allows
 42 " you to keep an undo history for multiple files when re-using the same window
 43 " in this way. Note that using persistent undo also lets you undo in multiple
 44 " files even in the same window, but is less efficient and is actually designed
 45 " for keeping undo history after closing Vim entirely. Vim will complain if you
 46 " try to quit without saving, and swap files will keep you safe if your computer
 47 " crashes.
 48 set hidden
 49 
 50 " Note that not everyone likes working this way (with the hidden option).
 51 " Alternatives include using tabs or split windows instead of re-using the same
 52 " window as mentioned above, and/or either of the following options:
 53 " set confirm
 54 " set autowriteall
 55 
 56 " Better command-line completion
 57 set wildmenu
 58 
 59 " Show partial commands in the last line of the screen
 60 set showcmd
 61 
 62 " Highlight searches (use  to temporarily turn off highlighting; see the
 63 " mapping of  below)
 64 set hlsearch
 65 
 66 " Modelines have historically been a source of security vulnerabilities. As
 67 " such, it may be a good idea to disable them and use the securemodelines
 68 " script, .
 69 " set nomodeline
 70 
 71 
 72 "------------------------------------------------------------
 73 " Usability options {{{1
 74 "
 75 " These are options that users frequently set in their .vimrc. Some of them
 76 " change Vim's behaviour in ways which deviate from the true Vi way, but
 77 " which are considered to add usability. Which, if any, of these options to
 78 " use is very much a personal preference, but they are harmless.
 79 
 80 " Use case insensitive search, except when using capital letters
 81 set ignorecase
 82 set smartcase
 83 
 84 " Allow backspacing over autoindent, line breaks and start of insert action
 85 set backspace=indent,eol,start
 86 
 87 " When opening a new line and no filetype-specific indenting is enabled, keep
 88 " the same indent as the line you're currently on. Useful for READMEs, etc.
 89 set autoindent
 90 
 91 " Stop certain movements from always going to the first character of a line.
 92 " While this behaviour deviates from that of Vi, it does what most users
 93 " coming from other editors would expect.
 94 set nostartofline
 95 
 96 " Display the cursor position on the last line of the screen or in the status
 97 " line of a window
 98 set ruler
 99 
100 " Always display the status line, even if only one window is displayed
101 set laststatus=2
102 
103 " Instead of failing a command because of unsaved changes, instead raise a
104 " dialogue asking if you wish to save changed files.
105 set confirm
106 
107 " Use visual bell instead of beeping when doing something wrong
108 set visualbell
109 
110 " And reset the terminal code for the visual bell. If visualbell is set, and
111 " this line is also included, vim will neither flash nor beep. If visualbell
112 " is unset, this does nothing.
113 set t_vb=
114 
115 " Enable use of the mouse for all modes
116 if has('mouse')
117   set mouse=a
118 endif
119 
120 " Set the command window height to 2 lines, to avoid many cases of having to
121 " "press  to continue"
122 set cmdheight=2
123 
124 " Display line numbers on the left
125 set number
126 
127 " Quickly time out on keycodes, but never time out on mappings
128 set notimeout ttimeout ttimeoutlen=200
129 
130 " Use  to toggle between 'paste' and 'nopaste'
131 set pastetoggle=
132 
133 
134 "------------------------------------------------------------
135 " Indentation options {{{1
136 "
137 " Indentation settings according to personal preference.
138 
139 " Indentation settings for using 4 spaces instead of tabs.
140 " Do not change 'tabstop' from its default value of 8 with this setup.
141 set shiftwidth=4
142 set softtabstop=4
143 set expandtab
144 
145 " Indentation settings for using hard tabs for indent. Display tabs as
146 " four characters wide.
147 "set shiftwidth=4
148 "set tabstop=4
149 
150 
151 "------------------------------------------------------------
152 " Mappings {{{1
153 "
154 " Useful mappings
155 
156 " Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy,
157 " which is the default
158 map Y y$
159 
160 " Map  (redraw screen) to also turn off search highlighting until the
161 " next search
162 nnoremap  :nohl
163 
164 "------------------------------------------------------------