-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
185 lines (155 loc) · 3.91 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
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
if has('nvim')
set rtp^=~/.vim/
endif
execute pathogen#infect()
set t_Co=256
syntax enable
colorscheme elflord
set number
set nowrap
set mouse=a
set scrolloff=5
set sidescroll=1
set sidescrolloff=10
set nostartofline
" set spell
set spelllang=en_us
" Use smartcase
set ignorecase
set smartcase
" Highlight search results + incremental
set hlsearch
set incsearch
" use system clipboard
set clipboard=unnamedplus
" Allow sudo-write
function SuWrite()
if &readonly
doautocmd BufWritePre
w !sudo tee % > /dev/null
if v:shell_error
echo "Write Failed"
else
redraw!
e!
endif
else
w
endif
endfunction
command W exec "let cpos=getpos('.')" | exec SuWrite() | call setpos('.', cpos)
command Wq exec "let cpos=getpos('.')" | exec SuWrite() | call setpos('.', cpos) | q
" disable keybind in the terminal for this to work
nnoremap <C-s> :W<CR>
inoremap <C-s> <ESC>:W<CR>
" Disable Ex mode
map Q <Nop>
" fat-finger fix
command Q q
" Move tabs around
function ShiftTab(direction)
let tab_number = tabpagenr()
if a:direction == 0
if tab_number == 1
exe 'tabm' . tabpagenr('$')
else
exe 'tabm' . (tab_number - 2)
endif
else
if tab_number == tabpagenr('$')
exe 'tabm ' . 0
else
exe 'tabm ' . tab_number
endif
endif
return ''
endfunction
noremap <silent> <C-S-PageUp> :call ShiftTab(0)<CR>
noremap <silent> <C-S-PageDown> :call ShiftTab(1)<CR>
" Default indent properties
"set ts=4 sts=4 sw=4 noet ai
set ts=2 sts=2 sw=2 et ai
" Detect indent size and type
autocmd BufReadPost * :DetectIndent
" Set local PWD to file location
"autocmd BufEnter * silent! lcd %:p:h
" Trim trailing whitespace on save
autocmd BufWritePre * exec "let cpos=getpos('.')" | :%s/\s\+$//e | call setpos('.', cpos)
" Set folding options
" ### Disabled for performace ###
"set foldmethod=syntax
"set foldlevel=20
"map zz za
" Customize NERDCommenter commands
filetype plugin on
nmap <C-e> <plug>NERDCommenterToggle
xmap <C-e> <plug>NERDCommenterToggle
imap <C-e> <ESC><plug>NERDCommenterToggle i
nmap <leader>c<space> <plug>NERDCommenterToggle
xmap <leader>c<space> <plug>NERDCommenterToggle
"Customize NERDTree commands
set hidden " preserve buffer postion
let NERDTreeQuitOnOpen=1
let NERDTreeIgnore = ['\.pyc$']
let g:nerdtree_tabs_open_on_new_tab=0
let g:nerdtree_tabs_open_on_gui_startup=0
nmap \e :NERDTreeSteppedOpen<CR>
nmap <C-\> :NERDTreeSteppedOpen<CR>
" Tagbar shortcuts
command TT TagbarToggle
nmap tt :TagbarOpenAutoClose<CR>
" CtrlP
nmap \p :CtrlP<CR>
let g:ctrlp_switch_buffer='ET'
" open in tab by default
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<c-t>'],
\ 'AcceptSelection("t")': ['<cr>', '<2-LeftMouse>'],
\ }
" Airline
set laststatus=2
set noshowmode
let g:airline#extensions#tabline#left_alt_sep=' '
" Uncomment to use patched fonts
let g:airline_powerline_fonts=1
" Airline instantly escape visual mode
if ! has('gui_running')
let g:airline#extensions#tabline#enabled=1 " dont show tabline in gvim
set ttimeoutlen=10
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
endif
" Syntastic
let g:syntastic_ignore_files=['ts']
" Custom keybinds
map <C-Up> 1<C-u>
map <C-Down> 1<C-d>
map <C-K> 1<C-u>
map <C-J> 1<C-d>
map <C-Left> z<Left><Left>
map <C-Right> z<Right><Right>
map <C-H> z<Left><Left>
map <C-L> z<Right><Right>
" Disable F1 help
map <F1> <Esc>
imap <F1> <Esc>
" Custom command shortcuts
command C let @/ = ""
command S set spell!
" Visual shortcuts
vnoremap . :normal .<CR>
vnoremap , :normal<Space>
vnoremap I :normal i
" Cursor
if &term =~ "xterm\\|rxvt"
" use a white cursor in insert mode
let &t_SI = "\<Esc>]12;white\x7"
" use a normal cursor otherwise
let &t_EI = "\033]112\007"
silent !echo -ne "\033]112\007"
" reset cursor when vim exits
autocmd VimLeave * silent !echo -ne "\033]112\007"
endif