vimRC

Vim

Public Domain

The vimrc file i've been lugging around/building for the past couple years.

Download (right click, save as, rename as appropriate)

Embed

Tags:

vim vim.rc vimrc
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
"o An example for a vimrc file.
"
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last change:	2002 Sep 19
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"	      for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"	    for OpenVMS:  sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
  finish
endif


" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

if has("vms")
  set nobackup		" do not keep a backup file, use versions instead
else
  set backup		" keep a backup file
endif
set history=50		" keep 50 lines of command line history
set ruler		" show the cursor position all the time
set showcmd		" display incomplete commands
set incsearch		" do incremental searching
set shiftwidth=4
set softtabstop=4
set tabstop=4
set expandtab
set autoindent
set ic 
set guitablabel=%N/\ %t\ %M "Show the number, filename, and modification state of each tab on it's title.
"set spell " Turn on spellchecking for comments - I'll probably turn this off later due to it's
          " annoyingness.
" set clipboard=autoselect
"
"No sound on errors.
set novisualbell
set t_vb=
set noerrorbells

"show matching braces
set showmatch

" Always enable the mouse.
set mouse=a

" Show line numbers
set number

" Set the tags file for our source dir
set tags=/devel/megatouch/source/tags

let g:miniBufExplModSelTarget = 1
let g:miniBufExplorerMoreThanOne = 0
let g:miniBufExplModSelTarget = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplVSplit = 25
let g:miniBufExplSplitBelow=1

map <c-w><c-t> :WMToggle<cr>

""""""""""""""""""""""""""""""
" Statusline
""""""""""""""""""""""""""""""
set laststatus=2

function! CurDir()
 let curdir = substitute(getcwd(), '/home/merit-projects/branches/V25_00/megatouch', "megatouch", "g")
 return curdir
endfunction

"set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
set statusline=\ %(%n\ %t%)%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c

""""""""""""""""""""""""""""""
" Visual
""""""""""""""""""""""""""""""
" From an idea by Michael Naumann
function! VisualSearch(direction) range
  let l:saved_reg = @"
  execute "normal! vgvy"
  let l:pattern = escape(@", '\\/.*$^~[]')
  let l:pattern = substitute(l:pattern, "\n$", "", "")
  if a:direction == 'b'
    execute "normal ?" . l:pattern . "^M"
  else
    execute "normal /" . l:pattern . "^M"
  endif
  let @/ = l:pattern
  let @" = l:saved_reg
endfunction

" Press * or # to search for the current selection !! Really useful
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>

"Switch to current dir
map <leader>cd :cd %:p:h<cr>

" Make the auto-complete even cooler
"set completeopt=longest,menuone
"inoremap <expr> <cr> pumvisible() ? "\<c-y>" : "\<c-g>u\<cr>"
"inoremap <expr> <c-n> pumvisible() ? "\<lt>c-n>" : "\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>" 
"inoremap <expr> <m-;> pumvisible() ? "\<lt>c-n>" : "\<lt>c-x>\<lt>c-o>\<lt>c-n>\<lt>c-p>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Use CTRL+t to open a new tab and gT/gt to move between open tabs.
" map <C-t> :tabnew<CR> 

" Don't use Ex mode, use Q for formatting
map Q gq
" set path=.,/usr/local/include,/usr/include,/home/megatouch/source/include,/home/megatouch/source/system/include,/home/merit-projects/megatouch/source/include,/home/merit-projects/megatouch/source/libs
set path=.,/usr/local/include,/usr/include,/usr/share/vim/vim70/doc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Iterate through mispelled words.
"map <leader>sn ]s
"map <leader>sp [s
" Add a word to the dictionary.
" map <leader>sa zg
" Get spelling suggestions.
"map <leader>s? z=

" Use the tab key for autocomplete, but only when it doesn't make sense to 
" insert a tab.
" function! InsertTabWrapper(direction) 
"      let col = col('.') - 1 
"      if !col || getline('.')[col - 1] !~ '\k' 
"          return "\<tab>" 
"      elseif "backward" == a:direction 
"          return "\<c-p>" 
"      else 
"          return "\<c-n>" 
"      endif 
" endfunction 
" 
" inoremap <tab> <c-r>=InsertTabWrapper ("forward")<cr>
" inoremap <s-tab> <c-r>=InsertTabWrapper ("backward")<cr>
"
set wildmenu

" Testing something that may not work:
" Place all .~ files in a subdirectory
set backupdir=./.backup,.,/tmp

" Set the color scheme
colorscheme elflord

"Auto-complete
" Exapand "#i" to #include
iab #i #include

" Expand #d to #define
iab #d #define

"Paste toggle - when pasting something in, don't indent.
set pastetoggle=<F3>

" Type "createclass" to paste an object outline 
iab createclass //! Class description
\
class Name
{
\
public:

//! Constructor
Name(void);
\//! Destructor
virtual ~Name(void);
\protected:
private:
}; 

" Type 'commentfunction' to create a Doxygen style
" function comment block.
iab commentfunction //! Brief Description
//! In-depth description
			\//! \param Name - First parameter
			\//! \return Returns \p x squared
			\//! \sa Function(const int &x)
			\

" Type 'commentheader' to create a Doxygen style
" file comment block for a header file.
iab commentheader //! \file filename.h
//! \brief This file contains the interface.
//! \author Dominic Dos Santos<br>
//! Copyright &copy; Merit Entertainment 2008
			\
//! More details.

#ifndef 
#define 
namespace 
{ 
} // namespace 
#endif // #ifndef 

" Type 'commentsource' to create a Doxygen style 
" file comment block for a source file.
iab commentsource //! \file filename.cpp
//! \brief This file contains the implementation.
//! \author Dominic Dos Santos<br>
//! Copyright &copy; Merit Entertainment 2008
//! More Details.

#include ".h" 
using namespace ;

" Type 'commentdef' to create a Doxygen style 
" macro comment block
iab commentdef //! \def MAX(a,b)
//! \brief A macro that returns.
			\
//! More information goes here.
			\

" Type 'commenttype' to create a Doxygen style
" typedef comment block.
iab commenttype /*! \var typedef unsigned int UINT32
			\	\brief A type definition of a.
			\More details.
*/

" Type four forward slashes to create an 80 column series of them
iab //// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

" Type //-- to create a seperator
iab //-- //--------------------------------------------------------------------------------------------------

" typos
iab anf and
iab adn and
iab ans and
iab teh the
iab thre there

" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  " filetype plugin indent on
  set cindent

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

  " For all text files set 'textwidth' to 78 characters.
  "autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal`\"" |
    \ endif

  augroup END

else

  set autoindent		" always set autoindenting on
  set expandtab
endif " has("autocmd")
highlight Pmenu guibg=brown gui=bold

set wildignore=*.o,*.obj,*.bak,*.exe,*~
nmap Y y$ 

set guioptions+=a