-
Notifications
You must be signed in to change notification settings - Fork 3
/
vimrc.server
228 lines (181 loc) · 7.15 KB
/
vimrc.server
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
" Author: reorx
" ============================================================================
" General
" ============================================================================
" Encoding
set encoding=utf-8
set fileencodings=utf-8,chinese,latin-1
set fileencoding=utf-8
set fencs=utf-8,chinese
syntax on
filetype on
set history=100
set nobackup
set autoread " When a file has been detected to have been changed outside of Vim and
" it has not been changed inside of Vim, automatically read it again.
" When the file has been deleted this is not done.
set ff=unix
set backspace=indent,eol,start
" Indent
set smarttab " a <Tab> in front of a line inserts blanks according to
" 'shiftwidth'. 'tabstop' or 'softtabstop' is used in other places
set shiftwidth=4 " Number of spaces to use for each step of (auto)indent.
set tabstop=4 " Number of spaces that a <Tab> in the file counts for.
set softtabstop=4 " Number of spaces that a <Tab> counts for while performing editing
" operations, like inserting a <Tab> or using <BS>.
set autoindent " Copy indent from current line when starting a new line
set expandtab " In Insert mode: Use the appropriate number of spaces to insert a
" <Tab>. Spaces are used in indents with the '>' and '<' commands and
" when 'autoindent' is on. To insert a real tab when 'expandtab' is
" on, use CTRL-V<Tab>
" Set 'tabstop' and 'shiftwidth' to whatever you prefer and use
" 'expandtab'. This way you will always insert spaces. The
" formatting will never be messed up when 'tabstop' is changed.
set smartindent " Do smart autoindenting when starting a new line. Works for C-like
" programs, but can also be used for other languages. 'cindent' does
" something like this, works better in most cases, but is more strict
inoremap # X<BS>#
" Search
set hlsearch
set incsearch
set smartcase
set ignorecase
set scrolloff=5
" Tabs
set tabpagemax=7
set showtabline=2
set splitright " To make vsplit put the new buffer on the right of the current buffer:
" Fold
set foldmethod=indent
"set foldlevel=2
set nofoldenable
" File Specials
autocmd FileType text setlocal textwidth=80
autocmd FileType crontab setlocal nowritebackup
au BufRead,BufNewFile *.json set ft=json syntax=javascript
au BufRead,BufNewFile *.conf set ft=dosini
au BufRead,BufNewFile *.pac set ft=javascript
" Display
set ruler " Show the line and column number of the cursor position, separated by a comma.
set showcmd " Show (partial) command in the last line of the screen.
set cmdheight=1 " Number of screen lines to use for the command-line.
"set number " Print the line number in front of each line.
set laststatus=2 " The value of this option influences when the last window will have a
" status line:
" 0: never
" 1: only if there are at least two windows
" 2: always
"set cursorline " Highlight the screen line of the cursor with CursorLine
set wildmenu " When 'wildmenu' is on, command-line completion operates in an enhanced
" mode. On pressing 'wildchar' (usually <Tab>) to invoke completion,
" the possible matches are shown just above the command line, with the
" first match highlighted (overwriting the status line, if there is
" one). Keys that show the previous/next match, such as <Tab> or
" CTRL-P/CTRL-N, cause the highlight to move to the appropriate match.
"set wildchar=
"set wildmode=
" netrw
let g:netrw_liststyle = 3
" A comma separated list of options for Insert mode completion
set completeopt=menu
" get rid of the fucking preview window
"set completeopt-=preview
" tab characters display dot
set list!
set listchars=tab:>-
"set list listchars=tab:»·
" highlight trailing whitespace
autocmd ColorScheme * highlight TrailWhitespace ctermbg=red guibg=red
highlight TrailWhitespace ctermbg=red guibg=red
match TrailWhitespace /\s\+$/
set mouse=a
" Prevent flashing when execute external command from vim
set shellpipe=&>
" ============================================================================
" UI
" ============================================================================
" Diff
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red
" Other highlights
highlight Visual cterm=reverse ctermbg=NONE
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
" ============================================================================
" Keymaps
" ============================================================================
" command+c copy, requires terminal send escape sequence "Esc+c" on command+c
vnoremap <M-c> "+y
" Leader key
"let mapleader = "\\"
let mapleader = " "
" Fix syntax highlighting, TODO with RainbowBraces
noremap <F5> <Esc>:syntax sync fromstart<CR>
inoremap <F5> <C-o>:syntax sync fromstart<CR>
noremap <leader>ss :call StripWhitespace()<CR>
" Save a file as root (,W)
noremap <leader>W :w !sudo tee % > /dev/null<CR>
" easier navigation between split windows
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
map tn :tabnew<cr>
map tc :tabclose<cr>
map <C-n> :tabnext<cr>
map <C-p> :tabprevious<cr>
nmap <Leader>[ :tabp<CR>
nmap <Leader>] :tabn<CR>
"map <C-]> :tabnext<cr>
"map <C-[> :tabprevious<cr>
" recover from accidental Ctrl-U
inoremap <C-U> <C-G>u<C-U>
inoremap <c-w> <c-g>u<c-w>
" Reload Vimrc
map <silent> <leader>V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
" ============================================================================
" Commands
" ============================================================================
" Strip trailing whitespace (\ss)
function! StripWhitespace()
let save_cursor = getpos(".")
let old_query = getreg('/')
:%s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfunction
func! DisableAutoIndent()
setlocal noautoindent
setlocal nocindent
setlocal nosmartindent
setlocal indentexpr=
echo 'Auto indent is disabled by many ways'
endfu
com! DisableAutoIndent call DisableAutoIndent()
func! SetTabstop(size)
let &l:tabstop=a:size
let &l:shiftwidth=a:size
let &l:softtabstop=a:size
endfu
com! -nargs=1 SetTabstop call SetTabstop(<f-args>)
" Spell check
" http://vimdoc.sourceforge.net/htmldoc/spell.html
" http://vim.wikia.com/wiki/Toggle_spellcheck_with_function_keys
func! ToggleSpell()
execute "setlocal spell! spelllang=en_us"
endfu
com! ToggleSpell call ToggleSpell()
" Disable numbers completely
func! NN()
execute "NumbersOnOff"
execute "NumbersToggle"
"setlocal nonumber
endfu
com! NN call NN()