-
Notifications
You must be signed in to change notification settings - Fork 0
/
_vimrc
284 lines (237 loc) · 10.3 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
272
273
274
275
276
277
278
279
280
281
282
283
284
" Location of .vimrc
" ==================
"
" Unix $HOME/.vimrc
" Windows $HOME\_vimrc or $VIMR\vimrc
"
" How to install pathogen
" ==============================================================================
"
" cd ~/.vim
" git clone https://github.com/tpope/vim-pathogen.git
" mkdir bundle
"
" How to install 'molokai' colors
" ==============================================================================
"
" cd colors
" git clone https://github.com/tomasr/molokai.git
"
" How to install 'solarized' colors
" ==============================================================================
"
" cd bundle
" git clone https://github.com/altercation/vim-colors-solarized.git
"
" How to install vim-ps1 plugin
" ==============================================================================
"
" cd bundle
" git clone https://github.com/PProvost/vim-ps1.git
"
" How to install vim-markdown plugin
" ==============================================================================
"
" cd bundle
" git clone https://github.com/tpope/vim-markdown.git
"
" How to install vim-snipmate plugin
" ==============================================================================
"
" cd bundle
" git clone https://github.com/tomtom/tlib_vim.git
" git clone https://github.com/MarcWeber/vim-addon-mw-utils.git
" git clone https://github.com/garbas/vim-snipmate.git
" Optional:
" git clone https://github.com/honza/vim-snippets.git
"
" How to change end-of-line format for dos-mac-unix
" =================================================
" http://vim.wikia.com/wiki/File_format
"
" convert from dos/unix to unix
" -----------------------------
" :update "Save any changes
" :e ++ff=dos "Edit file again, using dos file format
" :setlocal ff=unix "This buffer will use LF-only line endings when written
" :w "Write buffer using unix (LF-only) line endings
"
" convert from dos/unix to dos
" ----------------------------
" :update "Save any changes
" :e ++ff=dos "Edit file again, using dos file format
" :w "Write buffer using dos (CRLF) line endings
filetype off
" use pathogen.vim to manage and load plugins
execute pathogen#infect()
syntax on " switch syntax highlighting on
filetype plugin on " enable file type detection, use the default filetype settings
filetype indent on " load indent files, to automatically do language-dependent indenting
set nocompatible " no vi compatibility
set modelines=0 " prevent some exploits having to do with modelines in files
" === Plugin specific settings =================================================
" --- solarized colors ---
"colorscheme solarized " set the colorscheme
"set background=dark " set to 'dark' or 'light'
" --- molokai colors ---
colorscheme molokai " set the colorscheme
syntax on "switch syntax highlighting on
" Input support
set backspace=indent,eol,start " backspacing over everything in insert mode
" Command completion
set wildignore+=*.git,*.hg,*.svnj " version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiles object files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=*.orig " merge resolution file
set wildignore+=*.bak,*.swp,*~ " backup files
set wildignore+=*.class
set wildmenu " command-line completion in an enhanced mode
set wildmode=longest,list,full
" Search
set hlsearch " highlight the last used search pattern
set incsearch " do incremental searching
set ignorecase " searches are case insensitive
set smartcase " override 'ignorecase' when pattern has upper case characters
set scrolloff=4 " minimal number of lines to keep above and below the cursor
" Size of new GVim window
if has("gui_running")
set lines=80
set columns=180
set colorcolumn=81
set guioptions-=T " no toolbar in GUI
endif
set listchars=tab:>.\,eol:\$ " strings to use in 'list' mode
set fillchars=fold:\ , " get rid of obnoxious '-' characters in folds
set number " show the line number for each line
set cursorline " highlight the screen line of the cursor
set autoindent " automatically set the indent of a new line
set autoread " read open files again when changed outside Vim
set autowrite " write a modified buffer on each :next
set browsedir=current " which directory to use for the file browser
set clipboard=unnamed " copy to Windows clipboard
set complete+=k " scan the files given with the 'dictionary' option
set encoding=utf-8 " character encoding used in vim: 'latin1', 'utf-8', 'euc-jp', 'big5', etc.
set expandtab " use the appropriate number of spaces to insert a <Tab>
set tabstop=4 " number of spaces a <Tab> in the text stands for
set softtabstop=4 " number of spaces a <Tab> in the text stands for
set shiftwidth=4 " number of spaces used for each step of (auto)indent
set smarttab
set fileencodings=utf-8 " character encoding for the current file
set fileformats=dos,unix " format of the line ends
if has("folding")
set foldenable " enable folding
set foldmethod=syntax " the kind of folding (manual, indent, syntax, expr)
set foldlevelstart=99 " start editing with all folds open
" toggle folds
nnoremap <Space> za
vnoremap <Space> za
endif
set history=1000 " keep 1000 lines of command line history
" enable the use of the mouse
if has('mouse')
set mouse=a
endif
set mousehide " hide the mouse pointer when characters are typed
set nobackup " do not keep a backup file
set noerrorbells " do not beep
set noswapfile " turn of swap files
set wrap " do wrap lines
set nowritebackup
set ruler " display the current cursor position all the time
set shiftround " when at 3 spaces, and I hit > ... go to 4, not to 7
set showcmd " display incomplete commands
set showmatch " when inserting a bracket, briefly jump to its match
set showmode " display the mode
if exists('&breakindent')
set breakindent " Indent wrapped lines up to the same level
endif
set smartindent " do clever autodindenting
set spelllang=en,de " spell checking
try
if has("win32") || has("win64")
set guifont=Lucida_Console:h9:cDEFAULT
set directory=$TMP
set backupdir=$TMP " set the backup directory
set undodir=$TMP " set the undo directory
else
set guifont=Monospace:h10
set directory=/tmp
set backupdir=/tmp " set the backup directory
set undodir=/tmp " set the undo directory
endif
set undofile " saves undo history to an undo file
set undoreload=10000 " save the whole buffer for undo when reloading it
catch
endtry
set visualbell
set laststatus=2 " always display a status line at the bottom of the window
set statusline=
set statusline+=%7*\[%n] " buffer number
set statusline+=%1*\ %<%F\ " path to the file
set statusline+=%2*\ %y\ " file type
set statusline+=%3*\ %{''.(&fenc!=''?&fenc:&enc).''} " encoding
set statusline+=%3*\ %{(&bomb?\",BOM\":\"\")}\ " encoding2
set statusline+=%4*\ %{&ff}\ " file format (dos/unix)
set statusline+=%8*\ %=\ row:%l/%L\ (%p%%)\ " row number/total (%)
set statusline+=%9*\ col:%3c\ " col number
set statusline+=%0*\ \ %m%r%h%w\ %P\ \ " modified/readonly/help file/preview window flag, top/bottom
hi User1 guifg=#ffdad8 guibg=#880c0e
hi User2 guifg=#000000 guibg=#F4905C
hi User3 guifg=#292b00 guibg=#f4f597
hi User4 guifg=#112605 guibg=#aefe7B
hi User7 guifg=#ffffff guibg=#880c0e gui=bold
hi User8 guifg=#ffffff guibg=#5b7fbb
hi User9 guifg=#ffffff guibg=#810085
hi User0 guifg=#ffffff guibg=#094afe
if has("autocmd")
" when vimrc is edited, reload it
au BufWritePost _vimrc so $HOME\_vimrc
" remember last location in a file
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
" set custom file types
au BufNewFile,BufRead jquery.*.js,*.json set ft=javascript syntax=jquery
au BufNewFile,BufRead *.ps1,*.psm1,*.psc1 setf ps1
au BufNewFile,BufRead *.config setf xml
" markdown files
au BufNewFile,BufRead *.md setlocal filetype=markdown
" for ruby, autoindent with two spaces, always expand tabs
au FileType ruby,html,javascript,xml,xhtml set autoindent shiftwidth=2 softtabstop=2 expandtab
" set color for text files
au FileType text set filetype=markdown
endif
" Mappings
" ========
let mapleader=","
" movement with wrap turned on
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
nnoremap <Down> gj
nnoremap <Up> gk
vnoremap <Down> gj
vnoremap <Up> gk
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
" reselect visual block after indent/outdent
vnoremap < <gv
vnoremap > >gv
" ROT13 - fun
map <F12> ggVGg?
" smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" clear search highlighting with ESC
nnoremap <esc> :noh<cr><esc>
" moving lines with enter and shift enter
map <CR> o<Esc>k
map <S-Enter> O<Esc>j
" shortcut to rapidly toggle `set list`
nmap <leader>l :set list!<CR>
" insert blank lines without going into insert mode
nmap t o<ESC>k
nmap T O<ESC>j