-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
223 lines (163 loc) · 4.18 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
" Vundle requires this
set nocompatible
set hidden
" enable syntax highlighting
syntax enable
colorscheme monokai
" don't wrap lines
set nowrap
" keep the cursor in the middle of the screen
set scrolloff=15
" expand tabs to spaces
set expandtab
" autoindenting
set autoindent
set copyindent
set shiftround
set showmatch
" ignore case if search pattern is all lowercase, case-sensitive otherwise
set smartcase
" show line numbers
set relativenumber
set nonumber
" highlight current line
set cursorline
" disable arrow keys
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" highlight search terms, but clear on esc
set hlsearch
" show search matches during typing
set incsearch
set history=1000
set undolevels=1000
" ignore files during autocompletion
set wildignore=*.pyc
" change leader key
let mapleader = " "
" change terminal title
set title
" don't fully autocomplete filenames
set wildmode=list:longest,full
" don't use terminal bell
set visualbell
set noerrorbells
set t_vb=
" who needs it?!
set nobackup
set noswapfile
" tab = 4 spaces by default
set tabstop=2
set softtabstop=2
set shiftwidth=2
" quickly change tab width
nnoremap <leader>h :call TabWidthToggle()<CR>
function! TabWidthToggle()
if &tabstop == 2
set tabstop=4
set softtabstop=4
set shiftwidth=4
echo "Tab width set to 4"
else
set tabstop=2
set softtabstop=2
set shiftwidth=2
echo "Tab width set to 2"
endif
endfunction
" handy shortcuts
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
" color 81th column
let &colorcolumn=0
nnoremap <leader>f :call ColorColumnToggle()<CR>
function! ColorColumnToggle()
if &colorcolumn
set colorcolumn=0
else
set colorcolumn=81
endif
endfunction
" shortcut for paste mode
nnoremap <leader>p :set paste!<CR>
" show that there are more characters in a long line
set nolist
set listchars=extends:#,precedes:#,tab:▸\ ,eol:¬
nmap <leader>l :set list!<CR>
set ttimeoutlen=10
" shift+;+w = ;+w
"nnoremap ; :
" enable mouse scrolling
set mouse=a
" w!! saves the file with sudo
cmap w!! w !sudo tee % >/dev/null
" Remove trailing whitespace on file save
autocmd BufWritePre * :%s/\s\+$//e
" Don't mess up html files
let html_no_rendering=1
" Open new panes on the right and below
set splitbelow
set splitright
" %% expands into path to current file
cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr>
" open file in current file's directory
map <leader>ew :e %%
map <leader>et :tabe %%
set encoding=utf-8
" disable highlighting after search
map <leader>s :noh<CR>
" :Wrap enables line wrapping
command! -nargs=* Wrap set wrap linebreak nolist
" Set up Vundle
filetype off
set runtimepath+=~/.vim/bundle/Vundle.vim
call vundle#rc()
Bundle 'VundleVim/Vundle.vim'
Bundle 'kien/ctrlp.vim'
Bundle 'supertab'
Bundle 'vim-airline/vim-airline'
Bundle 'vim-airline/vim-airline-themes'
"Bundle 'godlygeek/tabular'
"Bundle 'plasticboy/vim-markdown'
Bundle 'scrooloose/nerdcommenter'
"Bundle 'wikitopian/hardmode'
"Bundle 'easymotion/vim-easymotion'
Bundle 'airblade/vim-gitgutter'
call vundle#end()
filetype plugin indent on
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_buffers = 0
let g:airline_left_sep=''
let g:airline_right_sep=''
let g:airline_theme='monokai'
" show airline when there is only one tab
set laststatus=2
" Relative numbers
" Relative line numbering only in sone cases
function! NumberToggle()
if &relativenumber
set number
set norelativenumber
else
set relativenumber
set nonumber
endif
endfunc
nnoremap <C-x> :call NumberToggle()<cr>
" Switch to absolute numbers when vim loses focus
:au FocusLost * :set number
:au FocusGained * :set relativenumber
" Switch to absolute numbers when going into insert mode
autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber
" ==============================================================================
" Commenter shortcuts
" ==============================================================================
" Ctrl+k toggles comments
nmap <C-k> <leader>c<leader>
augroup dex_ft
au!
autocmd BufNewFile,BufRead *.dx set syntax=haskell
augroup END