-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
216 lines (186 loc) · 8.34 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Filename: .vimrc "
" Maintainer: Felippe Nardi <[email protected]> "
" URL: http://github.com/felippenardi/dotfiles "
" "
" Based_on: Michael J. Smalley <[email protected]> "
" URL: http://github.com/michaeljsmalley/dotfiles "
" "
" "
" Sections: "
" 01. General ................. General Vim behavior "
" 02. Events .................. General autocmd events "
" 03. Theme/Colors ............ Colors, fonts, etc. "
" 04. Vim UI .................. User interface behavior "
" 05. Text Formatting/Layout .. Text, tab, indentation related "
" 06. Custom Commands ......... Any custom command aliases "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 01. General "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible " get rid of Vi compatibility mode. SET FIRST!
let mapleader = "," " change default leader key
set history=1000 " Increase command history limit
set splitbelow " Create new horizontal windows below
set splitright " Create new horizontal windows to the right
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 02. Events "
" Initiate pathogen before enabling filetype detection
call pathogen#infect()
call pathogen#helptags()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
filetype plugin indent on " filetype detection[ON] plugin[ON] indent[ON]
" In Makefiles DO NOT use spaces instead of tabs
autocmd FileType make setlocal noexpandtab
" In Ruby files, use 2 spaces instead of 4 for tabs
autocmd FileType ruby setlocal sw=2 ts=2 sts=2
" Enable omnicompletion (to use, hold Ctrl+X then Ctrl+O while in Insert mode.
set ofu=syntaxcomplete#Complete
" Enable spell check on commit message
autocmd BufNewFile,BufRead COMMIT_EDITMSG set spell
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 03. Theme/Colors "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set t_Co=256 " enable 256-color mode.
syntax enable " enable syntax highlighting (previously syntax on).
"colorscheme Tomorrow-Night-Eighties " set colorscheme
colorscheme Tomorrow " set colorscheme
" Prettify TODO files
autocmd BufRead,BufNewFile *.todo set filetype=todo
autocmd Syntax todo source ~/.vim/syntax/todo.vim
" Prettify Vagrantfile
autocmd BufRead,BufNewFile Vagrantfile set filetype=ruby
" Prettify Markdown files
"augroup markdown
" au!
" au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown
"augroup END
" Highlight characters that go over 80 columns (by drawing a border on the 81st)
if exists('+colorcolumn')
set colorcolumn=81
highlight ColorColumn ctermbg=grey
else
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+/
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 04. Vim UI "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set scrolloff=5 " minimal number of lines before and after cursor
set number " show line numbers
set numberwidth=2 " make the number gutter 6 characters wide
set cul " highlight current line
set laststatus=2 " last window always has a statusline
set nohlsearch " Don't continue to highlight searched phrases.
set incsearch " But do highlight as you type your search.
set ruler " Always show info along bottom.
set showmatch
set visualbell
let g:airline#extensions#tabline#enabled = 1 " Vim-airline smarter tab line
" Make search results appear on the middle of the screen
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 05. Text Formatting/Layout "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tabstop=2 " tab spacing
set softtabstop=2 " unify
set shiftwidth=2 " indent/outdent by 2 columns
set shiftround " always indent/outdent to the nearest tabstop
set expandtab " use spaces instead of tabs
set smartindent " automatically insert one extra level of indentation
set smarttab " use tabs at the start of a line, spaces elsewhere
set nowrap " don't wrap text
set autoindent " auto-indent
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 06. Custom Commands "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Save file by hitting return
function! Save()
w
if g:bottom_pane_toggle
silent exec "!tmux send-keys -t bottom C-up C-m" | redraw!
endif
endfunction
nnoremap <ENTER> :silent exec "call Save()"<ENTER>
" Toggle run last command on tmux bottom pane
nnoremap <leader>q :call BottomPaneToggle()<cr>
let g:bottom_pane_toggle = 0
function! BottomPaneToggle()
if g:bottom_pane_toggle
let g:bottom_pane_toggle = 0
else
let g:bottom_pane_toggle = 1
endif
endfunction
" Fold everything but last search:
" 1. Perform a search
" 2. Hit \z
nnoremap \z :setlocal foldexpr=(getline(v:lnum)=~@/)?0:(getline(v:lnum-1)=~@/)\\|\\|(getline(v:lnum+1)=~@/)?1:2 foldmethod=expr foldlevel=0 foldcolumn=0<CR>
" Easily create boxy characters for '0, 1, 3' scale
map ,m :s/0/▁/e<CR>:s/1/▅/e<CR>:s/3/▇/e<CR>:nohlsearch<cr>:echo <cr>
" Enable paste respecting identation
set pastetoggle=<F2>
" Moving selection
xmap <C-k> :mo'<-- <CR> gv
xmap <C-j> :mo'>+ <CR> gv
function! ScreencastMode()
GitGutterDisable
set numberwidth=1
set colorcolumn=810
endfunction
" Make Vim built-in explorer cool enough so I don't have to use NERDTree
" Toggle Vexplore with Ctrl-E
function! ToggleVExplorer()
if exists("t:expl_buf_num")
let expl_win_num = bufwinnr(t:expl_buf_num)
if expl_win_num != -1
let cur_win_nr = winnr()
exec expl_win_num . 'wincmd w'
close
exec cur_win_nr . 'wincmd w'
unlet t:expl_buf_num
else
unlet t:expl_buf_num
endif
else
exec '1wincmd w'
Vexplore
let t:expl_buf_num = bufnr("%")
endif
endfunction
map <silent> <C-E> :call ToggleVExplorer()<CR>
" Hit enter in the file browser to open the selected
" file with :vsplit to the right of the browser.
let g:netrw_browse_split = 4
let g:netrw_altv = 1
" Default to tree mode
let g:netrw_liststyle=3
" Quick cycle to next and previous buffer
nnoremap <S-Tab> gT
nnoremap <Tab> gt
" Quick Rename
function! RenameFile()
let old_name = expand('%:p')
let new_name = input('New file name: ', expand('%:p'), 'file')
if new_name != '' && new_name != old_name
exec ':silent w'
exec ':silent !mv ' . old_name . ' ' . new_name
exec ':silent !git rm ' . old_name
exec ':silent e ' . new_name
exec ':silent bd ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
" Make Ctrl+P skip .gitignore files
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
" Avoid mistakenly closing window when willing to cancel ctrl+w with a " ctrl+c
map <c-w><c-c> <space>
" Copy and paste between different vim instances
map <leader>y :w! /tmp/vim-clipboard<cr>
map <leader>p :r /tmp/vim-clipboard<cr>