-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvimrc
More file actions
167 lines (145 loc) · 4.86 KB
/
vimrc
File metadata and controls
167 lines (145 loc) · 4.86 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
"
" whim plugin loading
"
"
call pathogen#infect(expand("<sfile>:h") . '/bundle/{}')
call pathogen#infect()
syntax on
filetype plugin indent on
"
" Basic preferences
"
"
set nocompatible
set backspace=indent,eol,start
set backup " keep a backup file
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 ic " ignore case in searches
set hlsearch " highlight matching search terms
set viminfo='100,f1
set nu " show line numbers
set expandtab " replace tabs with spaces
set ts=2 showcmd sw=2 sts=2 " set all tab widths to 2
colorscheme molokai " set molokai as the default colorscheme
map Q gq
inoremap <C-U> <C-G>u<C-U>
if has("gui_macvim")
set mouse=a
else
set mouse=r
endif
"
" Our special key mappings
"
"
map <D-1> :tabn 1<CR>
map <D-2> :tabn 2<CR>
map <D-3> :tabn 3<CR>
map <D-4> :tabn 4<CR>
map <D-5> :tabn 5<CR>
map <D-6> :tabn 6<CR>
map <D-7> :tabn 7<CR>
map <D-8> :tabn 8<CR>
map <D-9> :tabn 9<CR>
" window splitting mappings
" split vertically with <leader> v
" split horizontally with <leader> s
nmap <leader>v :vsplit<CR> <C-w><C-w>
nmap <leader>s :split<CR> <C-w><C-w>
" Make it way easier to switch windows (<leader>w)
nmap <leader>w <C-w><C-w>_
" bind command-] to shift right
nmap <D-]> >>
vnoremap <D-]> ><CR>gv
imap <D-]> <C-O>>>
" bind command-[ to shift left
nmap <D-[> <<
vnoremap <D-[> <<CR>gv
imap <D-[> <C-O><<
" Press CTRL+N to toggle highlighting on/off, and show current value.
noremap <C-N> :set hlsearch! hlsearch?<CR>
" 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 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).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Javascript commands
function s:Minify(abspath, inpath, infile, outfile)
let myoutfile = a:inpath . '/' . a:outfile
if a:outfile == ''
let myoutfile = a:inpath . '/' . a:infile . '.min.js'
endif
exec ':silent !uglifyjs -nc -o ' . myoutfile . ' ' . a:abspath
echo 'Minified ' . a:abspath . ' to ' . myoutfile
endfunction
command! -nargs=? -complete=file Minify call <SID>Minify(expand("%:p"), expand("%:p:h"), expand("%:t:r"), <q-args>)
command Jslint :w | !jslint.js --devel --browser --white --onevar --undef --nomen --regexp --plusplus --bitwise --newcap --maxerr=5 --indent=2 %
" Coffeescript commands
autocmd BufNewFile,BufRead *.coffee let b:coffeeAutoMake = 0
function s:CoffeeAutoMake()
if b:coffeeAutoMake == 1
silent CoffeeMake! -b | cwindow
else
silent CoffeeMake! -bp | cwindow
endif
endfunction
autocmd BufWritePost *.coffee call s:CoffeeAutoMake()
command Cake :w | !cake build:all
" Command-T preferences
let g:CommandTMaxFiles=30000
let g:CommandTMaxHeight=20
let g:CommandTMatchWindowAtTop=0
let g:CommandTMatchWindowReverse=1
" NERDTree shortcuts
" Pro Tip: <leader>o, <leader>w, <leader>r to find the
" open buffer in the current working directory
map <leader>o :NERDTree<CR>
map <leader>r :NERDTreeFind<CR>
" Recognize md files as markdown
au BufNewFile,BufRead *.md set filetype=markdown
" VCL Syntax
au BufRead,BufNewFile *.vcl :set ft=vcl
au! Syntax vcl source ~/.whim/bundle/syntax/vcl.vim
" Golang Syntax
au BufRead,BufNewFile *.go :set ft=golang
au! Syntax golang source ~/.whim/bundle/syntax/golang.vim
" Scala Syntax
au BufRead,BufNewFile *.scala :set ft=scala
au! Syntax scala source ~/.whim/bundle/syntax/scala.vim
" Backup and swap configuration
set wildignore+=*~,.git
silent !mkdir -p ~/.vim/swap
silent !mkdir -p ~/.vim/backups
set directory=~/.vim/swap//
set backupdir=~/.vim/backups
au BufWritePre * let &backupdir = expand("$HOME") . '/.vim/backups'
au BufWritePre * let &backupext = substitute(expand("%:p"), "\/", "_", "g")
" Disable acp by default
au VimEnter * AutoComplPopDisable
" So language syntax highlighting works in markdown using fenced code blocks
let g:markdown_fenced_languages = ['ruby', 'javascript', 'html', 'python', 'css']