forked from yeco/.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
204 lines (152 loc) · 6.07 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
set nocompatible " full vim
syntax enable " enable syntax highlighting
set encoding=utf8 " utf8 default encoding
call pathogen#infect() " load pathogen
filetype plugin indent on
noremap , \
let mapleader = ","
set scrolloff=3 " show 3 lines of context around the cursor
set autoread " set to auto read when a file is changed from the outside
set mouse=a " allow for full mouse support
set autowrite
set showcmd " show typed commands
set wildmenu " turn on WiLd menu
set wildmode=list:longest,list:full " activate TAB auto-completion for file paths
set wildignore+=*.o,.git,.svn,node_modules
set ruler " always show current position
set backspace=indent,eol,start " set backspace config, backspace as normal
set nomodeline " security
set hlsearch " highlight search things
set incsearch " go to search results as typing
set smartcase " but case-sensitive if expression contains a capital letter.
set ignorecase " ignore case when searching
set gdefault " assume global when searching or substituting
set magic " set magic on, for regular expressions
set showmatch " show matching brackets when text indicator is over them
set lazyredraw " don't redraw screen during macros, faster
set ttyfast " improves redrawing for newer computers
set fileformats=unix,mac,dos
set nobackup " prevent backups of files, since using vcs
set nowritebackup
set noswapfile
set shiftwidth=3 " set tab width
set softtabstop=3
set tabstop=3
set smarttab
set expandtab " use spaces, not tabs
set autoindent " set automatic code indentation
set hidden " allow background buffers w/out writing
set nowrap " don't wrap lines
set list " show hidden characters
set listchars=tab:\ \ ,trail:· " show · for trailing space, \ \ for trailing tab
set spelllang=en,es " set spell check language
set noeb vb t_vb= " disable audio and visual bells
set t_Co=256 " use 256 colors
set background=dark
colorscheme ir_black " terminal theme
if has("gui_running")
au GUIEnter * set vb t_vb= " disable visual bell in gui
set guioptions-=T " remove gui toolbar
set guioptions-=m " remove gui menubar
set linespace=2 " space between lines
set columns=160 lines=35 " window size
set cursorline " highlight current line
set colorcolumn=115 " show a right margin column
set guioptions+=LlRrb " crazy hack to get gvim to remove all scrollbars
set guioptions-=LlRrb
set guifont=Ubuntu\ Mono\ 12 " gui font
set background=dark
colorscheme jellybeans " gui theme
endif
" FOLDING
set foldenable " enable folding
set foldmethod=indent " most files are evenly indented
set foldlevel=99
" ADDITIONAL KEY MAPPINGS
" fast saving
nmap <leader>w :up<cr>
" fast escaping
imap jj <ESC>
" prevent accidental striking of F1 key
map <F1> <ESC>
imap <F1> <ESC>
" clear highlight
nnoremap <leader><space> :noh<cr>
" map Y to match C and D behavior
nnoremap Y y$
" yank entire file (global yank)
nmap gy ggVGy
" ignore lines when going up or down
nnoremap j gj
nnoremap k gk
" auto complete {} indent and position the cursor in the middle line
inoremap {<CR> {<CR>}<Esc>O
inoremap (<CR> (<CR>)<Esc>O
inoremap [<CR> [<CR>]<Esc>O
" fast window switching
map <leader>, <C-W>w
" cycle between buffers
map <leader>. :b#<cr>
" change directory to current buffer
map <leader>cd :cd %:p:h<cr>
" open file explorer
map <leader>n :NERDTreeToggle<cr>
" swap implementations of ` and ' jump to prefer row and column jumping
nnoremap ' `
nnoremap ` '
" indent visual selected code without unselecting and going back to normal mode
vmap > >gv
vmap < <gv
" pull word under cursor into lhs of a substitute (for quick search and replace)
nmap <leader>r :%s#\<<C-r>=expand("<cword>")<CR>\>#
" strip all trailing whitespace in the current file
nnoremap <leader>W :%s/\s\+$//e<cr>:let @/=''<CR>
" insert path of current file into a command
cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
" fast editing of the .vimrc
nmap <silent> <leader>ev :e $MYVIMRC<cr>
nmap <silent> <leader>sv :so $MYVIMRC<cr>
" allow saving when you forgot sudo
cmap w!! w !sudo tee % >/dev/null
" turn on spell checking
map <leader>spl :setlocal spell!<cr>
" spell checking shortcuts
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
"" ADDITIONAL AUTOCOMMANDS
" saving when focus lost (after tabbing away or switching buffers)
au FocusLost,BufLeave,WinLeave,TabLeave * silent! up
" open in last edit place
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
au QuickFixCmdPost *grep* cwindow
"" ABBREVIATIONS
" source $HOME/.vim/autocorrect.vim
"" PLUGIN SETTINGS
let g:netrw_liststyle=3 " use tree style for netrw
" Unimpaired
" bubble single lines
nmap <C-Up> [e
nmap <C-Down> ]e
" bubble multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv
" Command-T
let g:CommandTMaxHeight=20
let g:CommandTCancelMap=['<ESC>','<C-c>']
" Ack
set grepprg=ack
nnoremap <leader>a :Ack<space>
let g:ackhighlight=1
let g:ackprg="ack-grep -H --type-set jade=.jade --type-set stylus=.styl --type-set coffee=.coffee --nocolor --nogroup --column --ignore-dir=node_modules -G '^((?!min\.).)*$'"
" CoffeeScript
map <leader>cc :CoffeeCompile<cr>
map <silent> <leader>cm :CoffeeMake<cr> <cr>
"" LANGUAGE SPECIFIC
" Python
au FileType python set noexpandtab
" JavaScript
au BufRead,BufNewFile *.json set ft=javascript
"" STATUS LINE
set laststatus=2 " always hide the last status