forked from ryanb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
271 lines (210 loc) · 7.2 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
" call pathogen#infect()
" Example Vim configuration.
" Copy or symlink to ~/.vimrc or ~/_vimrc.
filetype off
filetype plugin indent on
set nocompatible " Must come first because it changes other options.
nnoremap <Space> <nop>
let mapleader = ","
" let mapleader = " "
" set mouse=a
set clipboard=unnamed
silent! call pathogen#runtime_append_all_bundles()
syntax enable " Turn on syntax highlighting.
filetype plugin indent on " Turn on file type detection.
set showcmd " Display incomplete commands.
set showmode " Display the mode you're in.
set backspace=indent,eol,start " Intuitive backspacing.
set hidden " Handle multiple buffers better.
set wildmenu " Enhanced command line completion.
set wildmode=list:longest " Complete files like a shell.
set ignorecase " Case-insensitive searching.
set smartcase " But case-sensitive if expression contains a capital letter.
set number " Show line numbers.
set ruler " Show cursor position.
set incsearch " Highlight matches as you type.
set hlsearch " Highlight matches.
set showmatch
set wildignore='tmp/*,*/tmp/*,*/tmp/**/*'
" Some options from
" http://stevelosh.com/blog/2010/09/coming-home-to-vim/#making-vim-more-useful
set encoding=utf-8
set fileencoding=utf-8
set autoindent
set cursorline
set modelines=0
set ttyfast
" set relativenumber if we are using a newer vim
if v:version >= 703 && has("autocmd")
autocmd BufEnter * set relativenumber
endif
set nowrap " Turn on line wrapping.
set scrolloff=3 " Show 3 lines of context around the cursor.
set title " Set the terminal's title
set visualbell " No beeping.
" Folding settings
set foldmethod=indent
set foldlevel=1
set foldnestmax=3
set nofoldenable
" Move lines up and down
" noremap <C-J> :m +1 <CR>
" noremap <C-K> :m -2 <CR>
" Duplicate a selection
" Visual mode: D
vmap D y'>p
" No Help, please
noremap <F1> <Esc>
set nobackup " Don't make a backup before overwriting a file.
set nowritebackup " And again.
set noswapfile
" set directory=$HOME/.vim/tmp " Keep swap files in one location
" set backupdir=$HOME/.vim/tmp
set tabstop=2 softtabstop=2 shiftwidth=2
set expandtab
set listchars=tab:»»,trail:·
set list
set laststatus=2 " Show the status line all the time
" Useful status information at bottom of screen
set statusline=[%n]\ %<%.99F\ %h%w%m%r%y\ %{fugitive#statusline()}%{exists('*CapsLockStatusline')?CapsLockStatusline():''}%=%-16(\ %l,%c-%v\ %)%P
noremap <Leader>pt :Neoformat prettiereslint<CR>
noremap <Leader>ff :Neoformat prettiereslint<CR>
noremap <Space><Space> :buffer #<CR>
" let g:solarized_termcolors=16
" colorscheme solarized
" set background=dark
" set t_Co=16
" colorscheme railscasts
" set background=dark
" solarized options
" let g:solarized_termcolors = 16
" let g:solarized_visibility = "high"
" let g:solarized_contrast = "high"
" let g:solarized_style = "dark"
" colorscheme solarized
syntax on
colorscheme solarized
set background=light
" Moving
nnoremap / /\v
vnoremap / /\v
" "makes j and k work the way you expect instead of working in some archaic
" “movement by file line instead of screen line” fashion."
nnoremap j gj
nnoremap k gk
" nnoremap <up> <nop>
" nnoremap <down> <nop>
" nnoremap <left> <nop>
" nnoremap <right> <nop>
" inoremap <up> <nop>
" inoremap <down> <nop>
" inoremap <left> <nop>
" inoremap <right> <nop>
" Speed up viewport scrolling
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Searching
set gdefault
" In visual mode, indent and keep selection
vmap > >gv
vmap < <gv
" Move selection up/down (add =gv to reindent after move)
vmap <D-S-Up> :m-2<CR>gv
vmap <D-S-Down> :m'>+<CR>gv
" Tab mappings.
noremap <leader>tt :tabnew<cr>
" noremap <leader>te :tabedit
noremap <leader>tc :tabclose<cr>
" noremap <leader>to :tabonly<cr>
noremap <leader>tn :tabnext<cr>
noremap <leader>tp :tabprevious<cr>
" noremap <leader>tf :tabfirst<cr>
" noremap <leader>tl :tablast<cr>
" noremap <leader>tm :tabmove
noremap <D-S-Left> :tabprevious<cr>
noremap <D-S-Right> :tabnext<cr>
" map <Leader>b :TMiniBufExplorer<cr>
" F2 toggles folding
inoremap <F2> <C-O>za
nnoremap <F2> za
onoremap <F2> <C-C>za
vnoremap <F2> zf
" Nerdtree (,n)
map <F3> :NERDTreeToggle \| :silent NERDTreeMirror<CR>
" Create a split on the given side.
" From http://technotales.wordpress.com/2010/04/29/vim-splits-a-guide-to-doing-exactly-what-you-want/ via joakimk.
nmap <leader><left> :leftabove vnew<CR>
nmap <leader><right> :rightbelow vnew<CR>
nmap <leader><up> :leftabove new<CR>
nmap <leader><down> :rightbelow new<CR>
" Ack/Quickfix windows
nmap <Leader>q :cclose<CR>
nmap <leader>h :noh<cr>
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
" Controversial...swap colon and semicolon for easier commands
" nnoremap ; :
" vnoremap ; :
" Source the vimrc file after saving it
if has("autocmd")
autocmd BufWritePost .vimrc source $MYVIMRC
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
autocmd BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab
autocmd BufNewFile,BufReadPost *.py set filetype=python
autocmd BufNewFile,BufReadPost *.py setl shiftwidth=2 expandtab
autocmd BufNewFile,BufReadPost *.go set filetype=go
autocmd BufNewFile,BufReadPost *.go setl shiftwidth=2 expandtab
autocmd BufNewFile,BufReadPost *.erb set filetype=eruby
" autocmd FileType go autocmd BufWritePre <buffer> Fmt
endif
" command! LargeFont :set guifont=Menlo:h18
" command! SmallFont :set guifont=Menlo:h11
if &t_Co > 2 || has("gui_runing")
syntax on
endif
" noremap <Leader>d <Esc>:call CleanClose(1)<CR>
"
" http://vim.wikia.com/wiki/Search_for_visually_selected_text
" Search for selected text, forwards or backwards.
" vnoremap <silent> * :<C-U>
" \let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
" \gvy/<C-R><C-R>=substitute(
" \escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
" \gV:call setreg('"', old_reg, old_regtype)<CR>
" vnoremap <silent> # :<C-U>
" \let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
" \gvy?<C-R><C-R>=substitute(
" \escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
" \gV:call setreg('"', old_reg, old_regtype)<CR>
"
function! CleanClose(tosave)
if (a:tosave == 1)
w!
endif
let todelbufNr = bufnr("%")
let newbufNr = bufnr("#")
if ((newbufNr != -1) && (newbufNr != todelbufNr) && buflisted(newbufNr))
exe "b".newbufNr
else
bnext
endif
if (bufnr("%") == todelbufNr)
new
endif
exe "bd".todelbufNr
endfunction
" Disable netrw's autocmd, since we're ALWAYS using NERDTree
runtime plugin/netRwPlugin.vim
augroup FileExplorer
au!
augroup END
let g:NERDTreeHijackNetrw = 0
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
" Ignore files in .gitignore
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
" Alias commands
command! W :w
command! MRU CtrlPMRU