-
Notifications
You must be signed in to change notification settings - Fork 5
/
.vimrc
105 lines (89 loc) · 2.46 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
execute pathogen#infect()
filetype plugin on
set showmatch
set expandtab
set tabstop=4
set shiftwidth=4
set ruler
set et
set ch=2 "vim command line height
syntax on
set hlsearch
highlight Normal guibg=grey80
highlight Cursor guibg=Green
set bs=2
set autoindent
set number
set laststatus=2
set ruler
set ignorecase
set smartcase
set history=1000
set mouse=a
filetype plugin on
" Search for ctags file recursing up directory structure stopping at $HOME
set tags+=tags;$HOME
colors Tomorrow-Night-Bright
nmap \| :NERDTreeFind<CR>
nmap <Bslash> :NERDTreeToggle<CR>
nmap ,/ <plug>NERDCommenterToggle
vmap ,/ <plug>NERDCommenterToggle
nnoremap Y y$
"""""""""""""""""""""""""""""
" Configure line numbers (https://jeffkreeftmeijer.com/vim-number/)
" Absolute: cursor/insert mode/unfocused buffer
" Relative: everywhere else
"""""""""""""""""""""""""""""
set number relativenumber
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
"""""""""""""""""""""""""""""
" Check .git/tags for ctags file
"""""""""""""""""""""""""""""
fun! FindTagsFileInGitDir(file)
let path = fnamemodify(a:file, ':p:h')
while path != '/'
let fname = path . '/.git/tags'
if filereadable(fname)
silent! exec 'set tags+=' . fname
endif
let path = fnamemodify(path, ':h')
endwhile
endfun
augroup CtagsGroup
autocmd!
autocmd BufRead * call FindTagsFileInGitDir(expand("<afile>"))
augroup END
"""""""""""""""""""""
" Use AG with ctrl+p
"""""""""""""""""""""
let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --hidden
\ --ignore .git
\ --ignore .svn
\ --ignore .hg
\ --ignore .DS_Store
\ --ignore "**/*.pyc"
\ -g ""'
"""""""""""""""""""""""
" Use AG for searching
"""""""""""""""""""""""
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
"""""""""""""""""""""""""""""""""""
" bind K to grep word under cursor
"""""""""""""""""""""""""""""""""""
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
"""""""""""""""""""""""""""""""""""""""""
" bind // to search for visual selection
"""""""""""""""""""""""""""""""""""""""""
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>