-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
159 lines (138 loc) · 3.56 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
"Pathogen"
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" Required for Vundle
set nocompatible
filetype off
"Vundle
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'Valloric/YouCompleteMe.git'
"Vundle
filetype plugin indent on
" Settings
syntax on
syntax enable
set nobackup
set noswapfile
set hidden
set tabstop=2
set shiftwidth=2
set softtabstop=2
"set expandtab "spaces instead of tabs
set autoindent
set smartindent
set nowrap
set incsearch
"set number
set ignorecase
set smartcase
set ruler
set foldmethod=syntax " Markers used for folding
set foldnestmax=10 " Deepest fold level
set nofoldenable " Set folding off by default
set foldlevel=1
set cursorline
"Mappings"
map <C-t><C-h> :tabp<CR>
map <C-t><C-l> :tabn<CR>
map <C-t><C-n> :tabnew<CR>
nmap ,f :FuzzyFinderFileWithCurrentBufferDir<CR>
nmap ,b :FuzzyFinderBuffer<CR>
nmap ,t :FuzzyFinderTaggedFile<CR>
map <C-J> <C-W>j
map <C-K> <C-W>k
map <C-H> <C-W>h
map <C-L> <C-W>l
" 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
" ack-grep
let g:ackprg="ack -H --nocolor --nogroup --column"
" Define a command to make it easier to use
command! -nargs=+ QFDo call QFDo(<q-args>)
" Function that does the work
function! QFDo(command)
" Create a dictionary so that we can
" get the list of buffers rather than the
" list of lines in buffers (easy way
" to get unique entries)
let buffer_numbers = {}
" For each entry, use the buffer number as
" a dictionary key (won't get repeats)
for fixlist_entry in getqflist()
let buffer_numbers[fixlist_entry['bufnr']] = 1
endfor
" Make it into a list as it seems cleaner
let buffer_number_list = keys(buffer_numbers)
" For each buffer
for num in buffer_number_list
" Select the buffer
exe 'buffer' num
" Run the command that's passed as an argument
exe a:command
" Save if necessary
update
endfor
endfunction
" Rename.vim - Rename a buffer within Vim and on the disk
"
" Copyright June 2007-2011 by Christian J. Robinson <heptite@gmail.com>
"
" Distributed under the terms of the Vim license. See ":help license".
"
" Usage:
"
" :Rename[!] {newname}
command! -nargs=* -complete=file -bang Rename call Rename(<q-args>, '<bang>')
function! Rename(name, bang)
let l:name = a:name
let l:oldfile = expand('%:p')
if bufexists(fnamemodify(l:name, ':p'))
if (a:bang ==# '!')
silent exe bufnr(fnamemodify(l:name, ':p')) . 'bwipe!'
else
echohl ErrorMsg
echomsg 'A buffer with that name already exists (use ! to override).'
echohl None
return 0
endif
endif
let l:status = 1
let v:errmsg = ''
silent! exe 'saveas' . a:bang . ' ' . l:name
if v:errmsg =~# '^$\|^E329'
let l:lastbufnr = bufnr('$')
if expand('%:p') !=# l:oldfile && filewritable(expand('%:p'))
if fnamemodify(bufname(l:lastbufnr), ':p') ==# l:oldfile
silent exe l:lastbufnr . 'bwipe!'
else
echohl ErrorMsg
echomsg 'Could not wipe out the old buffer for some reason.'
echohl None
let l:status = 0
endif
if delete(l:oldfile) != 0
echohl ErrorMsg
echomsg 'Could not delete the old file: ' . l:oldfile
echohl None
let l:status = 0
endif
else
echohl ErrorMsg
echomsg 'Rename failed for some reason.'
echohl None
let l:status = 0
endif
else
echoerr v:errmsg
let l:status = 0
endif
return l:status
endfunction