-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc.after
204 lines (158 loc) · 7.36 KB
/
vimrc.after
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
"########################## Main config ################################
syn on " Turn on syntax highlighting
set hidden " Hide buffers
set autoread " Autoread file if changed outside VIM (Only when the file hasn't changed locally)
set grepprg=ack " Set Ack instead of grep
set wildchar=<Tab> wildmenu wildmode=full " Enable the wild menu on tab in ex mode
let mapleader=","
set number
"==================== Colors ======================================
set background=dark " Set light barkground
let g:solarized_termcolors=256 " Set solarized console to 256 colors
set t_Co=256 " Set vim to 256 colors
colorscheme solarized " Color schema
"colorscheme molokai
set list! " Unset list
"==================== Status line =================================
set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
set laststatus=2 " Set last status
"===================== Spelling ===================================
set spell " Enable spell checking
set spelllang=en " Set spelling to English
"===================== Cursor =====================================
"set cursorcolumn " Column marker
"set cursorline " Set cursor
"===================== Indentation ================================
set autoindent " Autoindent new lines
set expandtab " Use spaces instead of tabs
set tabstop=4 " Set tabs to 2 whitespaces
set shiftwidth=4 " 2
"set softtabstop=2 " 2 space tabs
set mouse=a " Enable mouse support
set title " Set the title of the current file as xterm title
set shiftround " When at 3 spaces indent to 4 instead of 5
set textwidth=0 wrapmargin=0
" Special rules for Go
autocmd BufNewFile,BufRead *.go set tabstop=8
autocmd BufNewFile,BufRead *.go set noexpandtab
autocmd BufNewFile,BufRead *.go set shiftwidth=8
"autocmd FileType go autocmd BufWritePre <buffer> silent Fmt
"==================== History =====================================
set history=100 " Set history to 1000
set undofile
set dir=~/.vimswap//,/var/tmp//,/tmp//,. " Store swap files in fixed location, not current directory.
"==================== Search ======================================
set incsearch " Find as you type
set ignorecase " Case insensitive search
set smartcase " Match case only when a capital is used
set hlsearch " Highlight searches
"==================== Misc ========================================
set splitright " VSplit on the right instead of the left side
"########################## KEY BINDINGS ###################################
"==================== Disables ====================================
" Disable Ex mode
map Q <Nop>
" Disable `man WORD`
map K <Nop>
"==================== Plugins =====================================
" Toggle NerdTree
map <silent> <Leader>. :silent NERDTreeToggle<CR>
" Toggle BufferWindow
map <Leader>b :BuffergatorToggle<CR>
"==================== Windows =====================================
" Switch to window left
map <C-h> <C-w>h
" Switch to window right
map <C-j> <C-w>j
" Switch to window above
map <C-k> <C-w>k
" Switch to window below
map <C-l> <C-w>l
" Split window vertical
map <C-\> :vsp<CR>
" Split window horizontal
map <C-_> :sp<CR>
" Edit <file> in current working dir as current file
map <Leader>e :e <C-R>=expand("%:p:h") . '/'<CR>
" ^ split
map <Leader>s :sp <C-R>=expand("%:p:h") . '/'<CR>
" ^ vertical split
map <Leader>vs :vsp <C-R>=expand("%:p:h") . '/'<CR>
"==================== Buffers =====================================
" Switch to previous buffer
noremap <Leader><Leader> <C-^>
" Yank to OS Clipboard
noremap <Leader>y "*y
" Yank line to OS Clipboard
noremap <Leader>Y "*Y
"
noremap <C-d> :TagbarToggle<CR>
" Open spec file for the current JavaScript file
function! OpenSpecFile()
let file = matchlist(expand("%:p"), 'app/assets/javascripts\([A-Za-z_/]\+\).js')
execute "vsp spec/javascripts/" . file[1] . 'Spec.js'
endfunction
noremap <Leader>- :call OpenSpecFile()<CR>
"==================== Tools ======================================
" This mapping uses <cword> to get the word under the cursor, and searches for it in the current directory and all subdirectorie.
map <F9> :execute "vimgrep /" . expand("<cword>") . "/j **" <Bar> cw<CR>
"==================== Misc =======================================
" Redo command but leave cursor on current position
nmap . .`[
" Escape with jj
inoremap jj <ESC>
" Remove trailing spaces
nnoremap <leader>W %s/\s\+$//<cr>:let @/=''<cr>
" ================== GUI ONLY =====================================
if has("gui_running")
map <D-u> :Gist<CR>
map <D-C> :ColorHEX<CR>
" color moloai
endif
"########################### COMMANDS "####################################
" This command based on VimTip483 uses <cword> to get the word under the cursor, but also uses % to limit the search to the current file only
command GREP :execute 'vimgrep /'.expand('<cword>').'/gj '.expand('%') | copen
command Dark :set background=dark
command Light :set background=light
"command W :w
" Finally, this cabbrev uses CTRL-R CTRL-W to get the word under the cursor, limiting the search to files of the same type using expand("%:e")
cabbrev lvim
\ lvim /\<lt><C-R><C-W>\>/gj
\ **/*<C-R>=(expand("%:e")=="" ? "" : ".".expand("%:e"))<CR>
\ <Bar> lw
\ <C-Left><C-Left><C-Left>
" Scientific calculator
command! -nargs=+ Calc :py print <args>
py from cmath import *
"} </Commands>
if has("autocmd")
autocmd BufNewFile,BufRead Rakefile,Capfile,Gemfile,Guardfile,config.ru,*.rd,*.god setfiletype ruby
autocmd BufNewFile,BufRead *.styl setfiletype sass
autocmd BufNewFile,BufRead *.jade setfiletype haml
autocmd BufNewFile,BufRead *.mu setfiletype go
au BufNewFile,BufRead *.ejs set filetype=html
" Automatically delete fugitive buffers
autocmd BufReadPost fugitive://* set bufhidden=delete
autocmd BufNewFile,BufRead *.hamljs setfiletype haml
autocmd InsertEnter * set number
autocmd InsertLeave * set relativenumber
autocmd User fugitive
\ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
\ nnoremap <buffer> .. :edit %:h<CR> |
\ endif
endif
if has("gui_running")
" Get rid of annoying balloon error popups about ri -f simple. I don't care
" about hovers anyway
autocmd FileType ruby,eruby set noballooneval
set guioptions=egmt
set guifont="Source Code Pro for Powerline"
else
"set cursorline!
"set cursorcolumn!
endif
" Autosafe on focus lost, ignore warnings for new files
"au FocusLost * silent! wall
let g:github_user = "obscuren"
let g:github_token = "c44b908c49e745fe9022d43461f21fd1ccf61af4"
let g:gist_clip_command = "pbcopy"