-
Notifications
You must be signed in to change notification settings - Fork 5
/
vimrc
274 lines (214 loc) · 6.97 KB
/
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
"-----------------------------------------------------------------------
" Basic configuration.
filetype off " temporarily
call pathogen#runtime_append_all_bundles()
" Set leader to comma.
let mapleader = ","
" Don't redraw screen while executing macros.
set nolazyredraw
" Behave intelligently for type of file.
filetype plugin indent on
" Syntax highlighting.
function! SyntaxToggle()
execute "syntax" exists("g:syntax_on") ? "off" : "on"
endfunction
nmap <leader>s :call SyntaxToggle()<cr><C-l><cr>
syntax on
" Give more context in viewport.
set scrolloff=3
" Scroll viewport faster.
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
set nomodeline " for security reasons
set nocompatible
" Encoding and line breaks.
set encoding=utf-8
set ffs=unix,dos
set grepprg=grep\ -nH\ $*
" Completion for file open etc.
set wildmenu
set wildmode=list:longest
set wildignore+=*.log,*.pdf,*.swp,*.o,*.hi,*.py[co],*~
" Ignore these when using TAB key with :e
set suffixes=~,.aux,.bak,.bkp,.dvi,.hi,.o,.pdf,.gz,.idx,.log,.ps,.swp,.tar,.ilg,.bbl,.toc,.ind
" Create backup files ending in ~, in ~/tmp or, if
" that is not possible, in the working directory.
set backup
set backupdir=~/tmp,.
" Flexible backspace: allow backspacing over autoindent, line breaks, start of
" insert.
set backspace=indent,eol,start
" No audible bell.
set visualbell
" Show line and column position of cursor, with percentage.
set ruler
" Make tabs and trailing space visible on ,l
set listchars=tab:>-,trail:.
set list
nmap <silent> <leader>l :set invlist list?<cr>
" Show matching brackets.
set showmatch
set mat=5 " for half a sec
" Tabs: default is two spaces.
set expandtab
set tabstop=8 " real tabs are 8
set softtabstop=2
set shiftwidth=2 " for autoindent
set shiftround " indent to a multiple of shiftwidth
set autoindent
" Reflow paragraphs intelligently. using 'par'.
set formatprg="par -h -w78 -B=.,\?_A_a "
map <C-\> !}par -h -w78 -B=.,\?_A_a <cr>
" Go to nearest match as you type.
set incsearch
set ignorecase " ignore case in search and tags
set smartcase " unless the pattern contains uppercase
" Set title of window according to filename.
set title
" Show command on last line.
set showcmd
"" Disable arrow keys.
"map <up> <nop>
"map <down> <nop>
"map <left> <nop>
"map <right> <nop>
"imap <up> <nop>
"imap <down> <nop>
"imap <left> <nop>
"imap <right> <nop>
" Switch ' and `
nnoremap ' `
nnoremap ` '
" This sets soft wrapping:
" set wrap linebreak textwidth=0
:nmap ,w :w<cr>
" Don't force save when changing buffers
set hidden
" NOTE: Snipmate won't work in paste mode!
set pastetoggle=<F2> " formerly <C-a>
" Remember more commands.
set history=200
" Buffer movement (C-n - next, C-p - previous).
map <C-n> :bn<cr>
map <C-p> :bp<cr>
" Tab movement
" gt next tab
" gT prev tab
" 3gt tab 3
" Split window movement
map <F4> <C-W><C-W>
map <C-Up> <C-W><Up>
map <C-Down> <C-W><Down>
map <C-Right> <C-W><Right>
map <C-Left> <C-W><Left>
" Use <Leader>g to go to a url under cursor in UTL format <url:blah>
:map <Leader>g :Utl<cr>
:let g:utl_opt_highlight_urls='yes'
:let g:utl_cfg_hdl_mt_generic = 'silent !open "%p"&'
" s skips whitespace and puts cursor on next non-whitespace char
:map s :call search('\S','ceW')<cr>
" S skips preceding whitespace and puts cursor on last non-whitespace char
:map S :call search('\S','bceW')<cr>
" If for aesthetic reasons you want a left margin in writing text...
function! GutterLeft()
set number
highlight LineNr ctermfg=Black
endfunction
" Use space and backspace for quick navigation forward/back.
noremap <Space> <PageDown>
noremap <BS> <PageUp>
" for text files set width = 78 chars
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 g`\"" |
\ endif
" Highlight according to markdown conventions in text files.
augroup text
autocmd BufRead *.txt set ai formatoptions=tcroqn2 comments=n:>
augroup END
" Edit another file in the same directory as the current file
" uses expression to extract path from current file's path
" thanks Douglas Potts).
map <leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" Use zl to list buffers, and go to matching buffer
" Type part of bufname after prompt.
nmap zl :ls!<CR>:buf
" Visit todo list
nmap <Leader>td :e ~/Wiki/TodoList<CR>
function! SearchWiki(searchTerm)
exec ":vimgrep " . a:searchTerm . " ~/Wiki/*"
exec ":copen"
endfunction
command -nargs=1 Find call SearchWiki(<f-args>)
" Convert markdown buffer to PDF.
function Markdown2PDF()
let source = bufname("")
let basename = expand("%:r")
exec ":! markdown2pdf " . source
exec ":Utl openLink " . basename . ".pdf"
endfunction
map <Leader>p :call Markdown2PDF()<cr><cr>
" Read abbreviations file if present.
if filereadable(expand("~/.vim/abbrevs.vim"))
source ~/.vim/abbrevs.vim
endif
"-----------------------------------------------------------------------
" GUI Settings {
if has("gui_running")
colorscheme zenburn
set columns=80
" set guifont=DejaVu\ Sans\ Mono\ 8 " set in ~/.vimrc
set guioptions=ce
" ||
" |+-- use simple dialogs rather than pop-ups
" + use GUI tabs, not console style tabs
set lines=40
set mousehide " hide the mouse cursor when typing
endif
"-----------------------------------------------------------------------
" Scripts and addons. These are managed by pathogen and live in bundle/.
" Most of them are git submodules, so I can keep up to date
"
" To add a submodule,
" git submodule add URL bundle/NAME
" git submodule init
" git commit
" git push
"
" After 'git pull', if submodules were added, you may need to
" git submodule init
" git submodule update
" To remove a submodule,
" Delete the relevant line from the .gitmodules file.
" Delete the relevant section from .git/config.
" Run git rm --cached path_to_submodule (no trailing slash).
" Commit and delete the now untracked submodule files.
"
" NERD_tree (file browser)
map <leader>n :NERDTreeToggle<CR>
" fuzzyfinder (fuzzy filename completion)
nmap <leader>b :FufBuffer<CR>
nmap <leader>f :call fuf#givenfile#launch('', 0, '> ', split(glob('./**/*'), "\n"))<CR>
let g:fuf_file_exclude = '\v\~$|\.(o|pdf|dvi|hi|exe|dll|bak|swp)$|(^|[/\\])\.(hg|git|bzr)($|[/\\])'
highlight Pmenu ctermbg=4 ctermfg=0
highlight PmenuSel ctermbg=0 ctermfg=4
" potwiki (personal wiki)
let potwiki_home = "$HOME/Wiki/WelcomePage"
function UploadICAL()
let source = bufname("")
let fullname = expand("%")
exec ":! icalupload.py " . fullname
endfunction
map <Leader>ui :call UploadICAL()<cr>
" ,cd changes working directory to directory of file being edited
map ,cd :cd %:p:h<CR>
"-----------------------------------------------------------------------
" Custom digraphs
dig cl 8988 " left corner quote U+231C
dig cr 8989 " right corner quote U+231D
" makes vim default register = the system clipboard
set clipboard+=unnamed