-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc.after
108 lines (94 loc) · 3.05 KB
/
.vimrc.after
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
" color ir_black
colorscheme molokai
color molokai
set guifont=Menlo:h14
" hide macvim toolbar:
set guioptions-=T
" use width-4 tabs for c languages
au FileType c,objc,cpp set tabstop=4 shiftwidth=4 softtabstop=4
au BufRead,BufNewFile *.less set filetype=scss
" recognize json
au! BufRead,BufNewFile *.json set filetype=json
" enable persistent undo
set undodir=/tmp/
set undofile
set colorcolumn=120
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Clear the search highlights when hitting return
nnoremap <CR> :nohlsearch<cr>
" Switch between buffers with leader leader
nnoremap <leader><leader> <c-^>
" map ,e and ,v to open files in the same directory as the current file
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>e :edit %%
map <leader>v :view %%
" taken from: http://stackoverflow.com/questions/356126/how-can-you-automatically-remove-trailing-whitespace-in-vim/1618401#1618401
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
" auto-strip trailing white space for ruby files
autocmd BufWritePre *.rb :call <SID>StripTrailingWhitespaces()
" command to strip white space from any file
nnoremap <leader>s :call <SID>StripTrailingWhitespaces()<cr>
" Keep text selected after shifting it left or right.
vmap < <gv
vmap > >gv
" Clean up XML
" http://vim.wikia.com/wiki/Pretty-formatting_XML
function! DoPrettyXML()
" save the filetype so we can restore it later
let l:origft = &ft
set ft=
" delete the xml header if it exists. This will
" permit us to surround the document with fake tags
" without creating invalid xml.
1s/<?xml .*?>//e
" insert fake tags around the entire document.
" This will permit us to pretty-format excerpts of
" XML that may contain multiple top-level elements.
0put ='<PrettyXML>'
$put ='</PrettyXML>'
silent %!xmllint --format -
" xmllint will insert an <?xml?> header. it's easy enough to delete
" if you don't want it.
" delete the fake tags
2d
$d
" restore the 'normal' indentation, which is one extra level
" too deep due to the extra tags we wrapped around the document.
silent %<
" back to home
1
" restore the filetype
exe "set ft=" . l:origft
endfunction
command! PrettyXML call DoPrettyXML()
augroup json_autocmd
autocmd!
autocmd FileType json set autoindent
autocmd FileType json set formatoptions=tcq2l
autocmd FileType json set textwidth=78 shiftwidth=2
autocmd FileType json set softtabstop=2 tabstop=8
autocmd FileType json set expandtab
autocmd FileType json set foldmethod=syntax
augroup END
" 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>
" make lint ignore angular directives
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]