-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
executable file
·155 lines (134 loc) · 4.22 KB
/
Copy pathvimrc
File metadata and controls
executable file
·155 lines (134 loc) · 4.22 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
set nocompatible " not vi compatible
" Theme
packadd! dracula
colorscheme dracula
"------------------
" Syntax and indent
"------------------
syntax enable " turn on syntax highlighting
set showmatch " show matching braces when text indicator is over them
" highlight current line, but only in active window
augroup CursorLineOnlyInActiveWindow
autocmd!
autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
augroup END
filetype plugin indent on " enable file type detection
set autoindent
"---------------------
" Basic editing config
"---------------------
set shortmess+=I " disable startup message
set nu " number lines
set rnu " relative line numbering
set incsearch " incremental search (as string is being typed)
set hls " highlight search
" remove search highlight once done
nnoremap <Leader><space> :nohlsearch<CR>
set listchars=tab:>>,nbsp:~ " set list to see tabs and non-breakable spaces
set lbr " line break
set scrolloff=5 " show lines above and below cursor (when possible)
set laststatus=2
set backspace=indent,eol,start " allow backspacing over everything
set timeout timeoutlen=1000 ttimeoutlen=100 " fix slow O inserts
set lazyredraw " skip redrawing screen in some cases
set hidden " allow auto-hiding of edited buffers
set history=8192 " more history
set nojoinspaces " suppress inserting two spaces between sentences
" use 4 spaces instead of tabs during formatting
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
" smart case-sensitive search
set ignorecase
set smartcase
" tab completion for files/bufferss
set wildmode=longest,list
set wildmenu
" add custom tags filename
set tags+=./.ctags
" recursvly search tags file
set tags=./.ctags;$HOME
"--------------------
" Misc configurations
"--------------------
" open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
" quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" movement relative to display lines
nnoremap <silent> <Leader>d :call ToggleMovementByDisplayLines()<CR>
function SetMovementByDisplayLines()
noremap <buffer> <silent> <expr> k v:count ? 'k' : 'gk'
noremap <buffer> <silent> <expr> j v:count ? 'j' : 'gj'
noremap <buffer> <silent> 0 g0
noremap <buffer> <silent> $ g$
endfunction
function ToggleMovementByDisplayLines()
if !exists('b:movement_by_display_lines')
let b:movement_by_display_lines = 0
endif
if b:movement_by_display_lines
let b:movement_by_display_lines = 0
silent! nunmap <buffer> k
silent! nunmap <buffer> j
silent! nunmap <buffer> 0
silent! nunmap <buffer> $
else
let b:movement_by_display_lines = 1
call SetMovementByDisplayLines()
endif
endfunction
" toggle relative numbering
nnoremap <C-n> :set rnu!<CR>
" spell checking
set spelllang=en
" use the following to make spell check enable by default
" set spell
" Make F5 toggle spell check
nnoremap <F5> :setlocal spell! spelllang=en_us<CR>
" Use ]s pr [s to move between wrong words and use z= to
" see the suggestion for the wrong spell word
"---------------------
" Plugin configuration
"---------------------
" nerdtree
nnoremap <Leader>n :NERDTreeToggle<CR>
" ctrlp
nnoremap <Leader>; :CtrlP<CR>
nnoremap <Leader>. :CtrlPTag<CR>
let g:ctrlp_switch_buffer = 0
let g:ctrlp_show_hidden = 1
" easymotion
map <Space> <Plug>(easymotion-prefix)
" vim-indent-guides
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
" tagbar
nmap <F8> :TagbarToggle<CR>
" ack.vim, require `ag` (the silver searcher)
" fixes the issue of ack printing the outputi of ag to console
" copied from https://github.com/mileszs/ack.vim/issues/18
function Search(string) abort
let saved_shellpipe = &shellpipe
let &shellpipe = '>'
try
execute 'Ack!' shellescape(a:string, 1)
finally
let &shellpipe = saved_shellpipe
endtry
endfunction
nnoremap <Leader>f :call Search("")<left><left>
let g:ackprg = 'ag --nogroup --nocolor --column --silent'
let g:ackhighlight = 1
" YouCompleteMe
let g:ycm_autoclose_preview_window_after_completion = 1
" enable project-specific .vimrc
set exrc
set secure