-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
242 lines (179 loc) · 5.75 KB
/
vimrc
File metadata and controls
242 lines (179 loc) · 5.75 KB
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
" This must be first, because it changes other options as a side effect.
set nocompatible
" Use pathogen for clean separation of installed modules
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" Turn off beeps
set vb t_vb=
" Allow backgrounding buffers without writing them, and remember marks/undo
" for backgrounded buffers
set hidden
" Remember more commands and search history
set history=1000
" Make tab completion for files/buffers act like bash
set wildmenu
" Make searches case-sensitive only if they contain upper-case characters
set ignorecase
set smartcase
" Keep more context when scrolling off the end of a buffer
set scrolloff=3
" Allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Don't keep a backup or swap file
set nobackup
set noswapfile
" Show the cursor position all the time
set ruler
" Display incomplete commands
set showcmd
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" 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 enable
set background=dark
colorscheme desert
set guifont=DejaVu\ Sans\ Mono\ 11
endif
" Show trailing space and leading tabs
set lcs=tab:˷˷,trail:▓
" Set some reasonable defaults
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set autoindent
" set smartindent
set laststatus=2
set showmatch
set incsearch
" 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
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 72 characters.
autocmd FileType text setlocal textwidth=72
autocmd FileType cmake setlocal noet sw=2 ts=2
" For mail files set 'textwidth' to 72 characters.
autocmd FileType mail setlocal textwidth=72 columns=80
" 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 g`\"" |
\ endif
autocmd BufReadPost fugitive://* set bufhidden=delete
" Auto lcd to the current file's folder
autocmd BufEnter * silent! lcd %:p:h
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Wrap lines at 78 characters
set textwidth=78
" Highlighting search"
set hls
if has("gui_running")
" GRB: set font"
"set nomacatsui anti enc=utf-8 gfn=Monaco:h12
" GRB: set window size"
set lines=100
set columns=88
" GRB: highlight current line"
set cursorline
" GRB: hide the toolbar in GUI mode
set go-=mT
endif
:command! -nargs=1 -range SuperRetab <line1>,<line2>s/\v%(^ *)@<= {<args>}/\t/g
" GRB: add pydoc command
:command! -nargs=+ Pydoc :call ShowPydoc("<args>")
function! ShowPydoc(module, ...)
let fPath = "/tmp/pyHelp_" . a:module . ".pydoc"
:execute ":!pydoc " . a:module . " > " . fPath
:execute ":sp ".fPath
endfunction
" Always source python.vim for Python files
au FileType python run scripts/python.vim
au FileType cpp set et ci sts=4 sw=4 ts=4
au FileType cmp set et ci sts=4 sw=4 ts=4
au FileType conf set et ci sts=4 sw=4 ts=4
" Use custom python.vim syntax file
au! Syntax python run syntax/python.vim
let python_highlight_all = 1
let python_slow_sync = 1
" Use emacs-style tab completion when selecting files, etc
set wildmode=longest,list
" Put useful info in status line
set statusline=%<%f%=\ [%1*%M%*%n%R%H]\ %-19(%3l,%02c%03V%)%O'%02b'
hi User1 term=inverse,bold cterm=inverse,bold ctermfg=red
" Clear the search buffer when hitting return
nnoremap <CR> :nohlsearch<CR>/<BS>
if version >= 700
autocmd FileType python set omnifunc=pythoncomplete#Complete
let Tlist_Ctags_Cmd='~/bin/ctags'
endif
let mapleader=","
nnoremap <leader><leader> <c-^>
" Highlight current line
set cursorline
hi CursorLine cterm=NONE ctermbg=black
set cmdheight=2
set guioptions-=L
set guioptions=r
augroup myfiletypes
"clear old autocmds in group
autocmd!
"for ruby, autoindent with two spaces, always expand tabs
autocmd FileType ruby,haml,eruby,yaml set ai sw=2 sts=2 et
autocmd FileType python set sw=4 sts=4 et
augroup END
augroup HelpInTabs
autocmd!
autocmd! BufEnter *.txt call HelpInNewTab()
augroup END
" Display help in new tab
function! HelpInNewTab()
if &buftype == 'help'
execute "normal \<C-W>T"
endif
endfunction
set switchbuf=useopen
" Treat CMP files as CPP files (for SimCreator)
autocmd BufRead,BufNewFile *.cmp set ft=cpp
" Map ,e to open files in the same directory as the current file
map <leader>e :e <C-R>=expand("%:h")<cr>/
" Save file using sudo with :w!!
cmap w!! %!sudo tee %
" Navigate search lists using arrow keys
nmap <silent> <RIGHT> :cnext<CR>
nmap <silent> <RIGHT><RIGHT> :cnfile<CR><C-G>
nmap <silent> <LEFT> :cprev<CR>
nmap <silent> <LEFT><LEFT> :cpfile<CR><C-G>
if has("python")
run ropevim/rope.vim
endif
autocmd BufRead,BufNewFile *.feature set sw=4 sts=4 et
set number
set numberwidth=5
if has("gui_macvim")
set guifont=Menlo\ Regular:h16
endif
" Use w!! to force writing of a file via sudo
cmap w!! w !sudo tee % >/dev/null
" Make window navigation easier
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Use ii as a synonym for ESC
inoremap ii <Esc>