-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc.min
266 lines (218 loc) · 8.11 KB
/
.vimrc.min
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
" mloliee vimrc.min
set nocompatible " be iMproved, required
filetype off " required
filetype plugin indent on " required
" -----------------------------------------------------------
" Global
" -----------------------------------------------------------
set autowrite " Automatically :write before running commands
set clipboard=unnamed " For OSX clipboard
set encoding=utf-8 " UTF-8 is the encoding you want for your files
set hidden " Handle multiple buffers better.
set history=1000 " Store lots of :cmdline history
set hlsearch " Highlight search results
set incsearch " Makes search act like in modern browsers
set lazyredraw " Redraw only when we need to.
set laststatus=2 " Always display the status line
set novisualbell "
set noerrorbells " No error bells
set showmode " Show mode -- INSERT --
set showcmd " Show commands
set showmatch " Highlight matching [{()}]
set ttimeout " Fast VIM
set ttimeoutlen=100
set ttyfast
set undofile " Persistent undo
set undodir=~/.vim/undofiles " Do not add ~un files everywhere I go
set wildmode=list:longest " Complete files like a shell.
set wildmenu " Enhanced command line completion.
set spelllang=en " Check all regions of English.
syntax enable
" Disable modelines for security reasons
set modelines=0
set nomodeline
" Store swap files in fixed location, not current directory.
"
" The '//' at the end ensure the swap file name will be built from the complete
" path to the file with all path separators substituted to percent '%' signs.
"
" This will ensure file name uniqueness in the preserve directory.
set dir=~/.vimswap//,/var/tmp//,/tmp//,.
" -----------------------------------------------------------
" Style
" -----------------------------------------------------------
set background=dark " Dark bg
:hi cursorline cterm=none " Do not Highlight current line
set ruler " Display ruler
set relativenumber " Set relative number for fast dd/yy
set number " Display line number for current line
" Set basic colorscheme
if ! exists("patatetoy_custom_term_colors")
colorscheme delek
endif
" Set the terminal's title
if &term == 'screen'
set t_ts=k
set t_fs=\
elseif &term == 'screen' || &term == 'xterm'
set title
endif
" -----------------------------------------------------------
" Indent - Tabs/Spaces
" -----------------------------------------------------------
set nowrap " don't wrap lines
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set expandtab " use spaces, not tabs (optional)
set smarttab
set backspace=indent,eol,start " backspace through everything in insert mode
set autoindent " match indentation of previous line
set listchars=tab:▸\ ,eol:¬,trail:·,extends:>,precedes:<
" -----------------------------------------------------------
" Auto Commands
" -----------------------------------------------------------
augroup vimrcEx
autocmd!
autocmd BufRead *.aliases* setlocal ft=sh
autocmd BufRead *Jenkinsfile setlocal ft=groovy
autocmd BufRead ~/.dnsmasq.d/* setlocal ft=dnsmasq
autocmd BufRead *nginx/*.conf setlocal ft=nginx
autocmd BufRead *httpd/*.conf setlocal ft=apache
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
" https://github.com/thoughtbot/dotfiles/blob/master/vimrc#L34-L40
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Crontab http://calebthompson.io/crontab-and-vim-sitting-in-a-tree/
autocmd filetype crontab setlocal nobackup nowritebackup
" Let's tell Vim to automatically use absolute line numbers when we're in
" insert mode and relative numbers when we're in normal mode
autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber
" https://vim.fandom.com/wiki/Highlight_unwanted_spaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
augroup END
" -----------------------------------------------------------
" Configure Explorer
" -----------------------------------------------------------
let g:netrw_banner = 0
let g:netrw_winsize = 15
let g:netrw_preview = 1
let g:netrw_altv = 1
let g:netrw_fastbrowse = 2
let g:netrw_keepdir = 0
let g:netrw_retmap = 1
let g:netrw_silent = 1
let g:netrw_special_syntax = 1
" -----------------------------------------------------------
" Bindings, command key send <Char-0x02> value
" -----------------------------------------------------------
" Define , as leader key
let mapleader = ","
" Save with Cmd-s
nnoremap <Char-0x02>s :w<CR>
inoremap <Char-0x02>s <ESC>:w<CR>l
cnoremap <Char-0x02>s <C-c>:w<CR>l
vnoremap <Char-0x02>s <ESC>:w<CR>l
" Undo
nnoremap <Char-0x02>u u
inoremap <Char-0x02>u <ESC>u
vnoremap <Char-0x02>u <ESC>u
" Do things right, use hjkl instead of arrows
nnoremap j gj
nnoremap k gk
" Command mode nav
cnoremap <C-e> <End>
cnoremap <C-k> <Up>
cnoremap <C-j> <Down>
cnoremap <C-h> <Left>
cnoremap <C-l> <Right>
" Fast visual 2 search
vnoremap // y/\V<C-R>"<CR>
" delete without yanking
nnoremap <leader>d "_d
vnoremap <leader>d "_d
" replace currently selected text with default register without yanking it
vnoremap <leader>p "_dP
" Remove help
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" Open on new window
nnoremap <Char-0x02>& <C-w>v<C-w>l
inoremap <Char-0x02>& <Esc><C-w>v<C-w>l
cnoremap <Char-0x02>& <Esc><C-w>v<C-w>l
vnoremap <Char-0x02>& <Esc><C-w>v<C-w>l
" Tab managment
nnoremap <Char-0x02>@ :tabnew<CR>
inoremap <Char-0x02>@ <Esc>:tabnew<CR>
vnoremap <Char-0x02>@ <Esc>:tabnew<CR>
cnoremap <Char-0x02>@ <Esc>:tabnew<CR>
nnoremap <Char-0x02>n :tabnext<CR>
inoremap <Char-0x02>n <Esc>:tabnext<CR>
vnoremap <Char-0x02>n <Esc>:tabnext<CR>
cnoremap <Char-0x02>n <Esc>:tabnext<CR>
nnoremap <Char-0x02>p :tabprevious<CR>
inoremap <Char-0x02>p <Esc>:tabprevious<CR>
vnoremap <Char-0x02>p <Esc>:tabprevious<CR>
nnoremap <Char-0x02>p <Esc>:tabprevious<CR>
" Close vim
nnoremap <leader>q :wq!<CR>
" Exit with ! and close tab and buffer
nnoremap <Char-0x02>q :bd!<CR>
inoremap <Char-0x02>q <Esc>:bd!<CR>
" Remap window moves
nnoremap <left> <C-w>h
nnoremap <down> <C-w>j
nnoremap <up> <C-w>k
nnoremap <right> <C-w>l
" Indent line
nmap <S-Tab> <<
nmap <Tab> >>
vmap <S-Tab> <gv
vmap <Tab> >gv
" Move visual selection with Alt-j / Alt-k
vnoremap Ï :m '>+1<CR>gv=gv
vnoremap È :m '<-2<CR>gv=gv
" Insert new empty lines with Alt-o / Alt-O
nmap œ o<Esc>k
nmap Œ O<Esc>j
" Force sudo write
cmap w!! w !sudo tee > /dev/null %
" Yank all lines
nmap <leader>ya :%y+<CR>
" Paste toggle
set pastetoggle=<leader>°
" Display invisible chars
nmap <leader>l :set list!<CR>
" Turn off search highlight and previous matches
nnoremap <leader><space> :nohlsearch<CR>:call clearmatches()<CR>
" Enable/Disable spell checking
nnoremap <silent> <leader>gs :set spell!<CR>
" Center window vertically on next/previous search match
noremap n nzz
noremap N Nzz
" -----------------------------------------------------------
" Functions
" -----------------------------------------------------------
" Command alias, redraw window
command! -nargs=1 Silent
\ execute ':silent !clear'
\ | execute ':silent '.<q-args>
\ | execute ':redraw!'
" Return curent filename or current directory
function! GetSmartWd()
let dir = expand('%:p')
if dir != ""
return dir
else
return expand('%:p:h')
endif
endfunction