-
Notifications
You must be signed in to change notification settings - Fork 0
/
mac_vimrc.orig
406 lines (302 loc) · 9.38 KB
/
mac_vimrc.orig
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
execute pathogen#infect()
" [ vmath.vim ]
" Damian Conway's vmath plugin for vim as demonstrated at his OSCON 2013 "More
" Instantly Better Vim" presentation. Calculates the sum, average, min, and
" max for a visual region containing numbers.
" https://github.com/nixon/vim-vmath
vmap <expr> ++ VMATH_YankAndAnalyse()
nmap ++ vip++
noremap Q !!$SHELL<cr>
"g:multi_cursor_exit_from_insert_mode (Default: 1)
"g:multi_cursor_exit_from_visual_mode (Default: 1)
let g:multi_cursor_exit_from_insert_mode=0
"let $XIKI_DIR = "/Library/Ruby/Gems/1.8/gems/xiki-0.6.3"
"source $XIKI_DIR/etc/vim/xiki.vim
imap £ #
cmap £ #
map £ #
function! Now()
r !date -u +'\%Y\%m\%dT\%H\%M\%S'
endfunction
map <leader>now :call Now()<cr>
map <leader>no :call Now()<cr>
map <leader>[ :tabp<CR>
map <leader>] :tabn<CR>
map <leader>\| :vsplit<CR>
map <leader>- :split<CR>
"
" Run teminal commands from vim
imap <leader>x jk0ir!jkyy:@"<cr>
nmap <leader>x 0ir!jkyy:@"<cr>
" Strip out old "Run"
imap <leader>z jk0xx
nmap <leader>z 0xx
set hidden
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
set spelllang=en_gb
" size of a hard tabstop
set tabstop=4
" size of an "indent"
set shiftwidth=4
" a combination of spaces and tabs are used to simulate tab stops at a width
" other than the (hard)tabstop
set softtabstop=4
" always uses spaces instead of tab characters
set expandtab
" make "tab" insert indents instead of tabs at the beginning of a line
"set smarttab
"set smartindent
set number
map <C-l> :set nu!<CR>
"nnoremap <silent> <C-a> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
set ai " auto indenting
set history=10000 " keep 100 lines of history
set ruler " show the cursor position
set showcmd
set ignorecase
syntax on " syntax highlighting
set hlsearch " highlight the last searched term
:nnoremap // :nohlsearch<cr>
filetype plugin on " use the file type plugins
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
" {{{1 GUI
if has('gui_running')
set lines=70
set columns=100
set guioptions=cM
set guicursor=a:blinkon0
set cursorline
if has("gui_win32")
set guifont=Consolas:h10:cDEFAULT
elseif has("gui_macvim")
set guifont=Monaco:h12.00
map <D-t> :CommandT<CR>
endif
if has('spell')
set spell
set spelllang=en_gb
set spellfile=~/.vim/spell/spellfile.add
set spellsuggest=best,10
endif
endif
"FROM G.B.
set cursorline
"disable arrow keys
"map <up> :echo 'No!'<cr>
"map <down> :echo 'No!'<cr>
"map <left> :echo 'No!'<cr>
"map <right> :echo 'No!'<cr>
"imap <up> :echo 'No!'<cr>
"imap <down> :echo 'No!'<cr>
"imap <left> :echo 'No!'<cr>
"imap <right> :echo 'No!'<cr>
map <silent> <Up> :wincmd k<CR>
map <silent> <Down> :wincmd j<CR>
map <silent> <Left> :wincmd h<CR>
map <silent> <Right> :wincmd l<CR>
imap <silent> <Up> :wincmd k<CR>
imap <silent> <Down> :wincmd j<CR>
imap <silent> <Left> :wincmd h<CR>
imap <silent> <Right> :wincmd l<CR>
set shell=bash
"set shell=/bin/bash\ -i
"Lighter looking colors"
"set t_Co=8 " 256 colors
"set background=dark
color grb256
set t_Co=256
"color railscasts
set switchbuf=useopen
let mapleader=","
set showtabline=4
set cmdheight=2
syntax on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RENAME CURRENT FILE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
"Command-T
" Ctrl-p to access
" Ctrl-t to open in new tab
map <C-p> <Esc>:CommandT<CR>
imap <C-p> <Esc>:CommandT<CR>
inoremap jk <esc>
inoremap <esc> <esc>:echo 'No! Use: jk '<cr>i
" Insert the next charachter pressed and shift the rest of the line right
" <space><space> would add one space.
nmap <Space> i_jkr
"Remove whitespace on save
autocmd BufWritePre *.py :%s/\s\+$//e
autocmd BufWritePre *.php :%s/\s\+$//e
autocmd BufWritePre *.html :%s/\s\+$//e
autocmd BufWritePre *.css :%s/\s\+$//e
autocmd BufWritePre *.js :%s/\s\+$//e
autocmd BufWritePre .*rc :%s/\s\+$//e
autocmd BufWritePre *.todo :%s/\s\+$//e
autocmd BufWritePre *.m :%s/\s\+$//e
autocmd BufWritePre *.h :%s/\s\+$//e
<<<<<<< HEAD
=======
autocmd BufWritePre *.jade :%s/\s\+$//e
>>>>>>> local-commandt
autocmd BufWritePre *.yml :%s/\s\+$//e
autocmd BufWritePre *.j2 :%s/\s\+$//e
function! ToDoSettings()
"map <Leader><Leader> :s/\[\s\]/\[x\]<cr>//A<space>\|<space><C-r>=strftime('%F')<CR>jk:w<cr>
map <Leader><Leader> :s/\[\s\]/\[x\]<cr>//<CR>jk:w<cr>
map <Leader>u :s/\[x\]/\[\ \]<cr>//<CR>jk:w<cr>
setlocal ft=todo
endfunction
function! CodeLeaderSettings(langExe)
execute "map <Leader><Leader> :w<cr>:!" . a:langExe . " %<cr>"
execute "imap <Leader><Leader> jk:w<cr>:!" . a:langExe . " %<cr>"
endfunction
function! CppLeaderSetting()
execute "map <Leader><Leader> :wa<cr>:!make<cr>"
execute "imap <Leader><Leader> jk:wa<cr>:!make<cr>"
endfunction
au BufNewFile,BufRead *.php call CodeLeaderSettings("php")
au BufNewFile,BufRead *.rb call CodeLeaderSettings("ruby")
au BufNewFile,BufRead *.py call CodeLeaderSettings("python")
au BufNewFile,BufRead *.js call CodeLeaderSettings("node")
au BufNewFile,BufRead *.cpp call CppLeaderSetting()
au BufNewFile,BufRead *.todo call ToDoSettings()
au BufNewFile,BufRead *.txt call ToDoSettings()
au BufNewFile,BufRead *.scss set filetype=scss.css
if has("autocmd")
filetype plugin indent on
endif
au BufNewFile,BufRead *.hbs set filetype=html
au BufNewFile,BufRead *.ejs set filetype=html
nmap <C-s> :setlocal spell!<CR>
"nmap <C-s> :w<CR>
"imap <c-s> <Esc>:w<CR>a
imap <C-s> <Esc><C-s>
"gorlf
map <Leader>t :tabnew<Enter>
map <Leader>w :close<Enter>
command! Browser :! open -a Google\ Chrome.app "%"
set wildmenu
"PhpUnit Testing
function! RunPhpUnitTest(...)
:w
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;
if a:0
let file = a:1
:exec '!phpunit ' . file
else
:!phpunit
endif
endfunction
map <Leader>R :call RunPhpUnitTest()<cr>
map <Leader>r :call RunPhpUnitTest(@%)<cr>
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <Leader>a :!php artisan
"Bubble single lines (kicks butt)
""http://vimcasts.org/episodes/bubbling-text/
nmap <C-k> ddkP
nmap <C-j> ddp
"Bubble multiple lines
vmap <C-k> xkP`[V`]
vmap <C-j> xp`[V`]
set laststatus=2
"set statusline=%f\ -\ FileType:\ %y
set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%)
hi StatusLine ctermbg=Grey ctermfg=DarkGrey
"Much nicer filename autocompletion
"set wildmode=list:longest,list
set wildmode=longest:full,full
" Mac OS X ( copy, Paste )
vmap <C-c> y:call system("pbcopy", getreg("\""))<CR>
nmap <C-v><C-v> :call setreg("\"",system("pbpaste"))<CR>p
" Save folds
autocmd BufWrite * mkview
autocmd BufRead * silent loadview
function! List_and_goto_buffers()
exec ':buffers'
call inputsave()
let buffer = input('Buffer no: ')
call inputrestore()
exec ':b' . buffer
endfunction
" Buffer Leader mappings
map <leader>b :bn!<cr>
map <leader>l :call List_and_goto_buffers()<cr>
" Change inner word to contents of anonymous buffer
nmap <silent> cp "_ciw<C-R>"jk
" Mock an ide environment - editor, file list, notes
function! Ide()
exec ':vsplit'
exec ':vertical resize 20'
exec ':wincmd l'
exec ':split'
exec ':wincmd j'
exec ':resize 10'
exec ':wincmd h'
exec ':Explor'
endfunction
command! Ide call Ide()
" git pull and reload all buffers
fun! PullAndRefresh()
set noconfirm
!git pull
bufdo e!
set confirm
endfun
"
" Not ready for a short cut yet
"nmap <leader>gr call PullAndRefresh()
" pip install jsbeautifier
" Proper formatting of javascript
"autocmd FileType javascript setlocal equalprg=js-beautify\ --stdin
nnoremap <silent> <leader>e :call JSFormat()<cr>
function! JSFormat()
" Preparation: save last search, and cursor position.
let l:win_view = winsaveview()
let l:last_search = getreg('/')
" call esformatter with the contents form and cleanup the extra newline
execute ":%!~/.vim/bin/js-format.sh"
if v:shell_error
echoerr 'format script failed'
undo
return 0
endif
" Clean up: restore previous search history, and cursor position
call winrestview(l:win_view)
call setreg('/', l:last_search)
endfunction
set noautochdir
nnoremap <F4> :TlistToggle<CR>
nnoremap <F8> :!/opt/local/bin/ctags -R **/*.py<CR>
autocmd FileType python set omnifunc=pythoncomplete#Complete
" Only works on a mac
map ˚ :wincmd h<CR>k<CR>
map ∆ :wincmd h<CR>j<CR>
"" Leader short cuts to grow
map <leader>pmain iif __name__ == "__main__":jkomain(sys.argv[1:])
set wildignore=.o,.obj,.git,node_modules/**,app/node_modules/**,.DS_Store,.gitkeep
let g:CommandTTraverseSCM='pwd'
set colorcolumn=81
highlight ColorColumn ctermbg=59