This repository has been archived by the owner on Mar 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vimrc
235 lines (192 loc) · 6.62 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
" vimrc by bohoomil
" vim:ft=vim:
" pathogen
filetype off
call pathogen#infect()
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
let Vimplate = "/usr/bin/vimplate"
set nocompatible
set encoding=utf8
set modeline
filetype plugin on
syntax on
" "
" ui "
" "
" wrap'n'jump by display lines
"set background=dark
if &t_Co < 256
"if $TERM =~ '^linux'
colorscheme dc3c " colourscheme for the 8 colour linux term
else
colorscheme dc3
endif
set tw=0
set wrap
set linebreak
set display+=lastline
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
" buftabs
noremap <F11> :bprev<CR>
noremap <F12> :bnext<CR>
let g:buftabs_only_basename=1
let g:buftabs_separator = "."
let g:buftabs_marker_start = "["
let g:buftabs_marker_end = "]"
let g:buftabs_marker_modified = "*"
" statusline
set cmdheight=1 " command line height
set laststatus=2 " condition to show status line, 2=always.
set ruler " show cursor position in status line
set showmode " show mode in status line
set showcmd " show partial commands in status line
" fileformat, encoding, type, buffer num, RO/HELP/PREVIEW, mod flag, filepath; spacer; line pos, line/total, percentage
set statusline=%{&ff}\ \%{&fenc}\ \b%1.3n\ \%#StatusFTP#\%Y\ \%#StatusRO#\%R\ \%#StatusHLP#\%H\ \%#StatusPRV#\%W\ \%#StatusModFlag#\%M\ \%#StatusLine#\%f\%=\%1.7c\ \%1.7l/%L\ \%p%%
" NERDTree config
nmap <silent> <F9> :NERDTreeToggle<CR>
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\env','\.vim$', '\~$', '\.pyc$', '\.swp$', '\.egg-info$', '^dist$', '^build$']
let NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\~$']
let NERDTreeShowBookmarks=1
let NERDTreeHightlightCursorline=1
" "
" filetypes "
" "
" txt2tags
au BufNewFile,BufRead *.t2t set ft=txt2tags
au Filetype txt2tags source $HOME/.vim/syntax/txt2tags.vim
au BufNewFile,BufRead *.t2t set wrap
au BufNewFile,BufRead *.t2t set lbr
au! BufRead,BufNewFile *.json set filetype=json foldmethod=syntax
" latex
filetype plugin indent on
set grepprg=grep\ -nH\ $*
let g:tex_flavor = "xetex"
let g:Tex_DefaultTargetFormat = "pdf"
let g:Tex_CompileRule_pdf = "xelatex -interaction=nonstopmode $*"
let g:Tex_ViewRule_pdf = "acroread"
" Gentoo-specific settings for ebuilds. These are the federally-mandated
" required tab settings. See the following for more information:
" http://www.gentoo.org/proj/en/devrel/handbook/handbook.xml
" Note that the rules below are very minimal and don't cover everything.
" Better to emerge app-vim/gentoo-syntax, which provides full syntax,
" filetype and indent settings for all things Gentoo.
au BufRead,BufNewFile *.e{build,class} let is_bash=1|setfiletype sh
au BufRead,BufNewFile *.e{build,class} set ts=4 sw=4 noexpandtab
" tmux
let tmux = "/usr/share/vim/vim73/syntax/tmux.vim"
au BufRead,BufNewFile .tmux.conf set filetype=tmux.conf
au Syntax newlang source /usr/share/vim/vim73/syntax/tmux.vim
" logs
au BufNewFile,BufRead *.log set ft=messages
au BufNewFile,BufRead *.log{.*} set ft=messages
" Syntax highlighting for subtitle files
au BufNewFile,BufRead *.srt setf srt
au BufNewFile,BufRead *.mpsub setf mpsub
au BufNewFile,BufRead *.sub setf sub
au BufNewFile,BufRead Trolltech.conf,.mpdasrc,.xchm,.*toprc setf cfg
" other file types
if has("autocmd")
"always jump to the last cursor position
autocmd BufReadPost * if line("'\"")>0 && line("'\"")<=line("$")|exe "normal g`\""|endif
autocmd BufRead *.txt set tw=80 " limit width to n cols for txt files
"autocmd FileType eml set tw=80 " limit width to n cols for email files
autocmd BufRead *.eml set tw=0 fo=cq wm=0 " no automatic wrapping, rewrapping will wrap to 80
autocmd BufRead ~/.mutt/temp/mutt-* set tw=80 ft=mail " nocindent spell " width, mail syntax hilight, spellcheck
endif
" automatically give executable permissions if file
" begins with #! and contains '/bin/' in the path
au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "/bin/" | silent execute "!chmod a+x <afile>" | endif | endif
augroup mkd
autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:>
augroup END
" html conversion (:help 2html.vim)
let g:html_use_css = 1
let g:use_xhtml = 1
let g:html_use_encoding = "utf8"
let g:html_number_lines = 1
" "
" keyboard "
" "
" map keys to toggle functions
function! MapToggle(key, opt)
let cmd = ':set '.a:opt.'! \| set '.a:opt."?\<CR>"
exec 'nnoremap '.a:key.' '.cmd
exec 'inoremap '.a:key." \<C-O>".cmd
endfunction
command! -nargs=+ MapToggle call MapToggle(<f-args>)
" semicolon enters ex mode
map ; :
" space bar un-highligts search
noremap <silent> <Space> :silent noh<Bar>echo<CR>
" keys & functions
MapToggle <F5> spell
MapToggle <F6> hlsearch
set noexpandtab
set noautoindent " set noautoindent to prevent vim from
" inserting unwanted indents when pasting
set tabstop=2 " set tab keys to 2 spaces
set shiftwidth=2
set nu! " line numbering
set smartindent
set bs=2 " backspace
" tab key in visual mode
vmap <tab> >gv
vmap <S-tab> <gv
" leader
let mapleader = ","
let g:BASH_MapLeader = '.'
" urxvt home / end
" the second is for insert mode
map <Esc>[7~ <Home>
map <Esc>[8~ <End>
imap <Esc>[7~ <Home>
imap <Esc>[8~ <End>
"set nolist " list disables linebreak
imap <silent> <Down> <C-o>gj
imap <silent> <Up> <C-o>gk
nmap <silent> <Down> gj
nmap <silent> <Up> gk
nmap <silent> k gk
nmap <silent> j gj
" "
" mouse "
" "
if has('mouse')
set mouse=a
endif
set mousemodel=popup_setpos
" improves redrawing for newer computers
set tf
set nolazyredraw " turn off lazy redraw
set nohlsearch " highlight no search results
set wildmenu
set spelllang=en " set spelling lang
set clipboard=unnamed " yank and copy to X clipboard
" "
" searching & history "
" "
set hlsearch " highlight all search results
set incsearch " increment search
set ignorecase " case-insensitive search; opposite noignorecase
set smartcase " uppercase causes case-sensitive search
set wrapscan " searches wrap back to the top of file
set nobackup " don't create backup files
set noswapfile " don't create swap file
set history=50 " keep 50 lines of command line history
set incsearch " do incremental searching
" "
" misc "
" "
" allows writing to files with root priviledges
cmap w!! w !sudo tee % > /dev/null
" Show syntax highlighting groups for word under cursor
nmap <C-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc