├── .gitignore
├── README.md
├── init.vim
├── resources
└── vim_ui_look.jpg
└── vimrc
/.gitignore:
--------------------------------------------------------------------------------
1 | tags
2 | .DS_Store
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | This is a minimal Vim/[Neovim](https://github.com/neovim/neovim) configuration
4 | in just one file without external dependencies. The purpose is to provide a
5 | light-weight and ready-to-use Vim config for quick editing.
6 |
7 | The config is tested in Vim 7.4, Vim 8.0 and Nvim 0.4.0.
8 |
9 |
10 |
11 |
12 |
13 |
14 | # How to use
15 |
16 | ## For Neovim
17 |
18 | To use this config for Neovim, use the following command:
19 |
20 | ```bash
21 | mkdir -p ~/.config/nvim && cd ~/.config/nvim
22 | git clone https://github.com/jdhao/minimal_vim.git .
23 | ```
24 |
25 | ## For Vim
26 |
27 | ```bash
28 | # to avoid default conf interfering with this conf
29 | mv ~/.vimrc ~/.vimrc.bak
30 | mkdir -p ~/.vim && cd ~/.vim
31 | git clone https://github.com/jdhao/minimal_vim.git .
32 | ```
33 |
--------------------------------------------------------------------------------
/init.vim:
--------------------------------------------------------------------------------
1 | set encoding=utf-8
2 | scriptencoding utf-8
3 |
4 | "{ Builtin optional plugins
5 | " Activate matchit plugin
6 | runtime! macros/matchit.vim
7 |
8 | " Activate man page plugin
9 | runtime! ftplugin/man.vim
10 | "}
11 |
12 | "{ Builtin options and settings
13 | if !has('nvim')
14 | " Change cursor shapes based on whether we are in insert mode,
15 | " see https://vi.stackexchange.com/questions/9131/i-cant-switch-to-cursor-in-insert-mode
16 | let &t_SI = "\[6 q"
17 | let &t_EI = "\[2 q"
18 | if exists('&t_SR')
19 | let &t_SR = "\[4 q"
20 | endif
21 |
22 | " The number of color to use
23 | set t_Co=256
24 | endif
25 |
26 | " Use English as default
27 | language en_US.utf-8
28 |
29 | filetype plugin indent on
30 | syntax enable
31 |
32 | " Set height of status line
33 | set laststatus=2
34 |
35 | " Changing fillchars for folding, so there is no garbage charactes
36 | set fillchars=fold:\ ,vert:\|
37 |
38 | " Paste mode toggle, it seems that Neovim's bracketed paste mode
39 | " does not work very well for nvim-qt, so we use good-old paste mode
40 | set pastetoggle=
41 |
42 | " Split window below/right when creating horizontal/vertical windows
43 | set splitbelow splitright
44 |
45 | " Time in milliseconds to wait for a mapped sequence to complete,
46 | " see https://unix.stackexchange.com/q/36882/221410 for more info
47 | set timeoutlen=500
48 |
49 | " For CursorHold events
50 | set updatetime=800
51 |
52 | " Clipboard settings, always use clipboard for all delete, yank, change, put
53 | " operation, see https://stackoverflow.com/q/30691466/6064933
54 | set clipboard+=unnamed
55 | set clipboard+=unnamedplus
56 |
57 | " Disable creating swapfiles, see https://stackoverflow.com/q/821902/6064933
58 | set noswapfile
59 |
60 | " General tab settings
61 | set tabstop=4 " number of visual spaces per TAB
62 | set softtabstop=4 " number of spaces in tab when editing
63 | set shiftwidth=4 " number of spaces to use for autoindent
64 | set expandtab " expand tab to spaces so that tabs are spaces
65 |
66 | " Set matching pairs of characters and highlight matching brackets
67 | set matchpairs+=<:>,「:」
68 |
69 | " Show line number and relative line number
70 | set number relativenumber
71 |
72 | " Ignore case in general, but become case-sensitive when uppercase is present
73 | set ignorecase smartcase
74 |
75 | " File and script encoding settings for vim
76 | set fileencoding=utf-8
77 | set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
78 |
79 | " Break line at predefined characters
80 | set linebreak
81 | " Character to show before the lines that have been soft-wrapped
82 | set showbreak=↪
83 |
84 | " List all items and start selecting matches in cmd completion
85 | set wildmode=list:full
86 |
87 | " Show current line where the cursor is
88 | set cursorline
89 |
90 | " Set a ruler at column 80, see https://stackoverflow.com/q/2447109/6064933
91 | set colorcolumn=80
92 |
93 | " Minimum lines to keep above and below cursor when scrolling
94 | set scrolloff=3
95 |
96 | " Use mouse to select and resize windows, etc.
97 | if has('mouse')
98 | set mouse=nic " Enable mouse in several mode
99 | set mousemodel=popup " Set the behaviour of mouse
100 | endif
101 |
102 | " Do not show mode on command line since vim-airline can show it
103 | set noshowmode
104 |
105 | " Fileformats to use for new files
106 | set fileformats=unix,dos
107 |
108 | " The mode in which cursorline text can be concealed
109 | set concealcursor=nc
110 |
111 | " The way to show the result of substitution in real time for preview
112 | if exists('&inccommand')
113 | set inccommand=nosplit
114 | endif
115 |
116 | " Ignore certain files and folders when globbing
117 | set wildignore+=*.o,*.obj,*.bin,*.dll,*.exe
118 | set wildignore+=*/.git/*,*/.svn/*,*/__pycache__/*,*/build/**
119 | set wildignore+=*.pyc
120 | set wildignore+=*.DS_Store
121 | set wildignore+=*.aux,*.bbl,*.blg,*.brf,*.fls,*.fdb_latexmk,*.synctex.gz,*.pdf
122 |
123 | " Ask for confirmation when handling unsaved or read-only files
124 | set confirm
125 |
126 | " Do not use visual and error bells
127 | set novisualbell noerrorbells
128 |
129 | " The level we start to fold
130 | set foldlevel=0
131 |
132 | " The number of command and search history to keep
133 | set history=500
134 |
135 | " Use list mode and customized listchars
136 | set list listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:+
137 |
138 | " Auto-write the file based on some condition
139 | set autowrite
140 |
141 | " Show hostname, full path of file and last-mod time on the window title. The
142 | " meaning of the format str for strftime can be found in
143 | " http://man7.org/linux/man-pages/man3/strftime.3.html. The function to get
144 | " lastmod time is drawn from https://stackoverflow.com/q/8426736/6064933
145 | set title
146 | set titlestring=
147 | set titlestring+=%(%{hostname()}\ \ %)
148 | set titlestring+=%(%{expand('%:p')}\ \ %)
149 | set titlestring+=%{strftime('%Y-%m-%d\ %H:%M',getftime(expand('%')))}
150 |
151 | " Persistent undo even after you close a file and re-open it.
152 | " For vim, we need to set up an undodir so that $HOME is not cluttered with
153 | " undo files.
154 | if !has('nvim')
155 | if !isdirectory($HOME . '/.local/vim/undo')
156 | call mkdir($HOME . '/.local/vim/undo', 'p', 0700)
157 | endif
158 | set undodir=~/.local/vim/undo
159 | endif
160 | set undofile
161 |
162 | " Completion behaviour
163 | set completeopt+=menuone " Show menu even if there is only one item
164 | set completeopt-=preview " Disable the preview window
165 |
166 | " Settings for popup menu
167 | set pumheight=15 " Maximum number of items to show in popup menu
168 | if exists('&pumblend')
169 | set pumblend=5 " Pesudo blend effect for popup menu
170 | endif
171 |
172 | " Scan files given by `dictionary` option
173 | set complete+=k,kspell complete-=w complete-=b complete-=u complete-=t
174 |
175 | set spelllang=en,cjk " Spell languages
176 |
177 | " Align indent to next multiple value of shiftwidth. For its meaning,
178 | " see http://vim.1045645.n5.nabble.com/shiftround-option-td5712100.html
179 | set shiftround
180 |
181 | " Virtual edit is useful for visual block edit
182 | set virtualedit=block
183 |
184 | " Correctly break multi-byte characters such as CJK,
185 | " see https://stackoverflow.com/q/32669814/6064933
186 | set formatoptions+=mM
187 |
188 | " Tilde (~) is an operator, thus must be followed by motions like `e` or `w`.
189 | set tildeop
190 |
191 | " Do not add two spaces after a period when joining lines or formatting texts,
192 | " see https://stackoverflow.com/q/4760428/6064933
193 | set nojoinspaces
194 |
195 | " Text after this column is not highlighted
196 | set synmaxcol=500
197 |
198 | " Increment search
199 | set incsearch
200 |
201 | set wildmenu
202 |
203 | " Do not use corsorcolumn
204 | set nocursorcolumn
205 |
206 | set backspace=indent,eol,start " Use backsapce to delete
207 | "}
208 |
209 | "{ Functions
210 | " Remove trailing white space, see https://vi.stackexchange.com/a/456/15292
211 | function! StripTrailingWhitespaces() abort
212 | let l:save = winsaveview()
213 | keeppatterns %s/\v\s+$//e
214 | call winrestview(l:save)
215 | endfunction
216 |
217 | " Custom fold expr, adapted from https://vi.stackexchange.com/a/9094/15292
218 | function! VimFolds(lnum)
219 | " get content of current line and the line below
220 | let l:cur_line = getline(a:lnum)
221 | let l:next_line = getline(a:lnum+1)
222 |
223 | if l:cur_line =~# '^"{'
224 | return '>' . (matchend(l:cur_line, '"{*') - 1)
225 | else
226 | if l:cur_line ==# '' && (matchend(l:next_line, '"{*') - 1) == 1
227 | return 0
228 | else
229 | return '='
230 | endif
231 | endif
232 | endfunction
233 |
234 | " Custom fold text, adapted from https://vi.stackexchange.com/a/3818/15292
235 | " and https://vi.stackexchange.com/a/6608/15292
236 | function! MyFoldText()
237 | let line = getline(v:foldstart)
238 | let folded_line_num = v:foldend - v:foldstart
239 | let line_text = substitute(line, '^"{\+', '', 'g')
240 | let fillcharcount = &textwidth - len(line_text) - len(folded_line_num) - 10
241 | return '+'. repeat('-', 4) . line_text . repeat('.', fillcharcount) . ' ('. folded_line_num . ' L)'
242 | endfunction
243 | "}
244 |
245 | "{ Variables
246 | let mapleader = ','
247 |
248 | " Do not load netrw by default since I do not use it, see
249 | " https://github.com/bling/dotvim/issues/4
250 | let g:loaded_netrwPlugin = 1
251 |
252 | " Do not load tohtml.vim
253 | let g:loaded_2html_plugin = 1
254 | "}
255 |
256 |
257 | "{ Auto commands
258 | " Do not use smart case in command line mode,
259 | " extracted from https://vi.stackexchange.com/q/16509/15292
260 | if exists('##CmdLineEnter')
261 | augroup dynamic_smartcase
262 | autocmd!
263 | autocmd CmdLineEnter : set nosmartcase
264 | autocmd CmdLineLeave : set smartcase
265 | augroup END
266 | endif
267 |
268 | " Set textwidth for text file types
269 | augroup text_file_width
270 | autocmd!
271 | " Sometimes, automatic filetype detection is not right, so we need to
272 | " detect the filetype based on the file extensions
273 | autocmd BufNewFile,BufRead *.md,*.MD,*.markdown setlocal textwidth=79
274 | augroup END
275 |
276 | if exists('##TermOpen')
277 | augroup term_settings
278 | autocmd!
279 | " Do not use number and relative number for terminal inside nvim
280 | autocmd TermOpen * setlocal norelativenumber nonumber
281 | " Go to insert mode by default to start typing command
282 | autocmd TermOpen * startinsert
283 | augroup END
284 | endif
285 |
286 | " More accurate syntax highlighting? (see `:h syn-sync`)
287 | augroup accurate_syn_highlight
288 | autocmd!
289 | autocmd BufEnter * :syntax sync fromstart
290 | augroup END
291 |
292 | " Return to last edit position when opening a file
293 | augroup resume_edit_position
294 | autocmd!
295 | autocmd BufReadPost *
296 | \ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
297 | \ | execute "normal! g`\"zvzz"
298 | \ | endif
299 | augroup END
300 |
301 | " Display a message when the current file is not in utf-8 format.
302 | " Note that we need to use `unsilent` command here because of this issue:
303 | " https://github.com/vim/vim/issues/4379. For older Vim (version 7.4), the
304 | " help file are in gzip format, do not warn this.
305 | augroup non_utf8_file_warn
306 | autocmd!
307 | autocmd BufRead * if &fileencoding != 'utf-8' && expand('%:e') != 'gz'
308 | \ | unsilent echomsg 'File not in UTF-8 format!' | endif
309 | augroup END
310 |
311 | augroup vimfile_setting
312 | autocmd!
313 | autocmd FileType vim setlocal foldmethod=expr foldlevel=0 foldlevelstart=-1
314 | \ foldexpr=VimFolds(v:lnum) foldtext=MyFoldText()
315 | \ keywordprg=:help formatoptions-=o formatoptions-=r
316 | augroup END
317 |
318 | augroup number_toggle
319 | autocmd!
320 | autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &number | set relativenumber | endif
321 | autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &number | set norelativenumber | endif
322 | augroup END
323 | "}
324 |
325 | "{ Custom key mappings
326 | " Save key strokes (now we do not need to press shift to enter command mode).
327 | " Vim-sneak has also mapped `;`, so using the below mapping will break the map
328 | " used by vim-sneak
329 | nnoremap ; :
330 | xnoremap ; :
331 |
332 | " Quicker way to open command window
333 | nnoremap q; q:
334 |
335 | " Quicker in insert mode
336 | inoremap jk
337 |
338 | " Turn the word under cursor to upper case
339 | inoremap viwUea
340 |
341 | " Turn the current word into title case
342 | inoremap b~lea
343 |
344 | " Paste non-linewise text above or below current cursor,
345 | " see https://stackoverflow.com/a/1346777/6064933
346 | nnoremap p m`op``
347 | nnoremap P m`Op``
348 |
349 | " Shortcut for faster save and quit
350 | nnoremap w :update
351 | " Saves the file if modified and quit
352 | nnoremap q :x
353 | " Quit all opened buffers
354 | nnoremap Q :qa
355 |
356 | " Navigation in the location and quickfix list
357 | nnoremap [l :lpreviouszv
358 | nnoremap ]l :lnextzv
359 | nnoremap [L :lfirstzv
360 | nnoremap ]L :llastzv
361 | nnoremap [q :cpreviouszv
362 | nnoremap ]q :cnextzv
363 | nnoremap [Q :cfirstzv
364 | nnoremap ]Q :clastzv
365 |
366 | " Close location list or quickfix list if they are present,
367 | " see https://superuser.com/q/355325/736190
368 | nnoremap \x :windo lclose cclose
369 |
370 | " Close a buffer and switching to another buffer, do not close the
371 | " window, see https://stackoverflow.com/q/4465095/6064933
372 | nnoremap \d :bprevious bdelete #
373 |
374 | " Toggle search highlight, see https://stackoverflow.com/q/9054780/6064933
375 | nnoremap hl (&hls && v:hlsearch ? ':nohls' : ':set hls')."\n"
376 |
377 | " Insert a blank line below or above current line (do not move the cursor),
378 | " see https://stackoverflow.com/a/16136133/6064933
379 | nnoremap oo 'm`' . v:count1 . 'o``'
380 | nnoremap OO 'm`' . v:count1 . 'O``'
381 |
382 | " nnoremap oo @='m`o``'
383 | " nnoremap OO @='m`O``'
384 |
385 | " the following two mappings work, but if you change double quote to single, it
386 | " will not work
387 | " nnoremap oo @="m`o\Esc>``"
388 | " nnoremap oo @="m`o\e``"
389 |
390 | " Insert a space after current character
391 | nnoremap ah
392 |
393 | " Yank from current cursor position to the end of the line (make it
394 | " consistent with the behavior of D, C)
395 | nnoremap Y y$
396 |
397 | " Move the cursor based on physical lines, not the actual lines.
398 | nnoremap j (v:count == 0 ? 'gj' : 'j')
399 | nnoremap k (v:count == 0 ? 'gk' : 'k')
400 | nnoremap ^ g^
401 | nnoremap 0 g0
402 |
403 | " Do not include white space characters when using $ in visual mode,
404 | " see https://vi.stackexchange.com/a/18571/15292
405 | xnoremap $ g_
406 |
407 | " Jump to matching pairs easily in normal mode
408 | nnoremap %
409 |
410 | " Go to start or end of line easier
411 | nnoremap H ^
412 | xnoremap H ^
413 | nnoremap L g_
414 | xnoremap L g_
415 |
416 | " Resize windows using and h,j,k,l, inspiration from
417 | " https://vim.fandom.com/wiki/Fast_window_resizing_with_plus/minus_keys (bottom page).
418 | " If you enable mouse support, shorcuts below may not be necessary.
419 | nnoremap <
420 | nnoremap >
421 | nnoremap -
422 | nnoremap +
423 |
424 | " Fast window switching, inspiration from
425 | " https://stackoverflow.com/a/4373470/6064933
426 | nnoremap h
427 | nnoremap l
428 | nnoremap j
429 | nnoremap k
430 |
431 | " Continuous visual shifting (does not exit Visual mode), `gv` means
432 | " to reselect previous visual area, see https://superuser.com/q/310417/736190
433 | xnoremap < >gv
435 |
436 | " When completion menu is shown, use to select an item
437 | " and do not add an annoying newline. Otherwise, is what it is.
438 | " For more info , see https://superuser.com/q/246641/736190 and
439 | " https://unix.stackexchange.com/q/162528/221410
440 | inoremap ((pumvisible())?("\"):("\"))
441 | " Use to close auto-completion menu
442 | inoremap ((pumvisible())?("\"):("\"))
443 |
444 | " Use to navigate down the completion menu.
445 | inoremap pumvisible()?"\":"\"
446 |
447 | " Edit and reload init.vim quickly
448 | nnoremap ev :edit $MYVIMRC
449 | nnoremap sv :silent update $MYVIMRC source $MYVIMRC
450 | \ echomsg "Nvim config successfully reloaded!"
451 |
452 | " Reselect the text that has just been pasted
453 | nnoremap v `[V`]
454 |
455 | " Search in selected region
456 | vnoremap / :call feedkeys('/\%>'.(line("'<")-1).'l\%<'.(line("'>")+1)."l")
457 |
458 | " Find and replace (like Sublime Text 3)
459 | nnoremap :%s/
460 | xnoremap :s/
461 |
462 | " Change current working directory locally and print cwd after that,
463 | " see https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file
464 | nnoremap cd :lcd %:p:h:pwd
465 |
466 | " Use Esc to quit builtin terminal
467 | if exists(':tnoremap')
468 | tnoremap
469 | endif
470 |
471 | " Toggle spell checking
472 | nnoremap :set spell!
473 | inoremap :set spell!
474 |
475 | " Decrease indent level in insert mode with shift+tab
476 | inoremap < :call StripTrailingWhitespaces()
486 |
487 | " Clear highlighting
488 | if maparg('', 'n') ==# ''
489 | nnoremap :nohlsearch=has('diff')?'diffupdate':''
490 | endif
491 |
492 | nnoremap :echoerr "Don't use arrow keys, use H, J, K, L instead!"
493 | nnoremap :echoerr "Don't use arrow keys, use H, J, K, L instead!"
494 | nnoremap :echoerr "Don't use arrow keys, use H, J, K, L instead!"
495 | nnoremap :echoerr "Don't use arrow keys, use H, J, K, L instead!"
496 | "}
497 |
498 | "{ UI settings
499 | if !has('gui_running')
500 | augroup MyColors
501 | autocmd!
502 | autocmd ColorScheme * call MyHighlights()
503 | augroup END
504 | else
505 | set guioptions-=T
506 | set guioptions-=m
507 | set guioptions-=r
508 | set guioptions-=L
509 | endif
510 |
511 | function! MyHighlights() abort
512 | highlight clear
513 |
514 | " The following colors are taken from ayu_mirage vim-airline theme,
515 | " link: https://github.com/vim-airline/vim-airline-themes/
516 | hi User1 ctermfg=0 ctermbg=114
517 | hi User2 ctermfg=114 ctermbg=0
518 |
519 | " The following colors are taken from vim-gruvbox8,
520 | " link: https://github.com/lifepillar/vim-gruvbox8
521 | hi Normal ctermfg=187 ctermbg=NONE cterm=NONE
522 | hi CursorLineNr ctermfg=214 ctermbg=NONE cterm=NONE
523 | hi FoldColumn ctermfg=102 ctermbg=NONE cterm=NONE
524 | hi SignColumn ctermfg=187 ctermbg=NONE cterm=NONE
525 | hi VertSplit ctermfg=59 ctermbg=NONE cterm=NONE
526 |
527 | hi ColorColumn ctermfg=NONE ctermbg=237 cterm=NONE
528 | hi Comment ctermfg=102 ctermbg=NONE cterm=italic
529 | hi CursorLine ctermfg=NONE ctermbg=237 cterm=NONE
530 | hi Error ctermfg=203 ctermbg=234 cterm=bold,reverse
531 | hi ErrorMsg ctermfg=234 ctermbg=203 cterm=bold
532 | hi Folded ctermfg=102 ctermbg=237 cterm=italic
533 | hi LineNr ctermfg=243 ctermbg=NONE cterm=NONE
534 | hi MatchParen ctermfg=NONE ctermbg=59 cterm=bold
535 | hi NonText ctermfg=239 ctermbg=NONE cterm=NONE
536 | hi Pmenu ctermfg=187 ctermbg=239 cterm=NONE
537 | hi PmenuSbar ctermfg=NONE ctermbg=239 cterm=NONE
538 | hi PmenuSel ctermfg=239 ctermbg=109 cterm=bold
539 | hi PmenuThumb ctermfg=NONE ctermbg=243 cterm=NONE
540 | hi SpecialKey ctermfg=102 ctermbg=NONE cterm=NONE
541 | hi StatusLine ctermfg=239 ctermbg=187 cterm=reverse
542 | hi StatusLineNC ctermfg=237 ctermbg=137 cterm=reverse
543 | hi TabLine ctermfg=243 ctermbg=237 cterm=NONE
544 | hi TabLineFill ctermfg=243 ctermbg=237 cterm=NONE
545 | hi TabLineSel ctermfg=142 ctermbg=237 cterm=NONE
546 | hi ToolbarButton ctermfg=230 ctermbg=59 cterm=bold
547 | hi ToolbarLine ctermfg=NONE ctermbg=59 cterm=NONE
548 | hi Visual ctermfg=NONE ctermbg=59 cterm=NONE
549 | hi WildMenu ctermfg=109 ctermbg=239 cterm=bold
550 | hi Conceal ctermfg=109 ctermbg=NONE cterm=NONE
551 | hi Cursor ctermfg=NONE ctermbg=NONE cterm=reverse
552 | hi DiffAdd ctermfg=142 ctermbg=234 cterm=reverse
553 | hi DiffChange ctermfg=107 ctermbg=234 cterm=reverse
554 | hi DiffDelete ctermfg=203 ctermbg=234 cterm=reverse
555 | hi DiffText ctermfg=214 ctermbg=234 cterm=reverse
556 | hi Directory ctermfg=142 ctermbg=NONE cterm=bold
557 | hi EndOfBuffer ctermfg=234 ctermbg=NONE cterm=NONE
558 | hi IncSearch ctermfg=208 ctermbg=234 cterm=reverse
559 | hi ModeMsg ctermfg=214 ctermbg=NONE cterm=bold
560 | hi MoreMsg ctermfg=214 ctermbg=NONE cterm=bold
561 | hi Question ctermfg=208 ctermbg=NONE cterm=bold
562 | hi Search ctermfg=214 ctermbg=234 cterm=reverse
563 | hi SpellBad ctermfg=203 ctermbg=NONE cterm=italic,underline
564 | hi SpellCap ctermfg=109 ctermbg=NONE cterm=italic,underline
565 | hi SpellLocal ctermfg=107 ctermbg=NONE cterm=italic,underline
566 | hi SpellRare ctermfg=175 ctermbg=NONE cterm=italic,underline
567 | hi Title ctermfg=142 ctermbg=NONE cterm=bold
568 | hi WarningMsg ctermfg=203 ctermbg=NONE cterm=bold
569 | hi Boolean ctermfg=175 ctermbg=NONE cterm=NONE
570 | hi Character ctermfg=175 ctermbg=NONE cterm=NONE
571 | hi Conditional ctermfg=203 ctermbg=NONE cterm=NONE
572 | hi Constant ctermfg=175 ctermbg=NONE cterm=NONE
573 | hi Define ctermfg=107 ctermbg=NONE cterm=NONE
574 | hi Debug ctermfg=203 ctermbg=NONE cterm=NONE
575 | hi Delimiter ctermfg=208 ctermbg=NONE cterm=NONE
576 | hi Error ctermfg=203 ctermbg=234 cterm=bold,reverse
577 | hi Exception ctermfg=203 ctermbg=NONE cterm=NONE
578 | hi Float ctermfg=175 ctermbg=NONE cterm=NONE
579 | hi Function ctermfg=142 ctermbg=NONE cterm=bold
580 | hi Identifier ctermfg=109 ctermbg=NONE cterm=NONE
581 | hi Ignore ctermfg=fg ctermbg=NONE cterm=NONE
582 | hi Include ctermfg=107 ctermbg=NONE cterm=NONE
583 | hi Keyword ctermfg=203 ctermbg=NONE cterm=NONE
584 | hi Label ctermfg=203 ctermbg=NONE cterm=NONE
585 | hi Macro ctermfg=107 ctermbg=NONE cterm=NONE
586 | hi Number ctermfg=175 ctermbg=NONE cterm=NONE
587 | hi Operator ctermfg=107 ctermbg=NONE cterm=NONE
588 | hi PreCondit ctermfg=107 ctermbg=NONE cterm=NONE
589 | hi PreProc ctermfg=107 ctermbg=NONE cterm=NONE
590 | hi Repeat ctermfg=203 ctermbg=NONE cterm=NONE
591 | hi SpecialChar ctermfg=203 ctermbg=NONE cterm=NONE
592 | hi SpecialComment ctermfg=203 ctermbg=NONE cterm=NONE
593 | hi Statement ctermfg=203 ctermbg=NONE cterm=NONE
594 | hi StorageClass ctermfg=208 ctermbg=NONE cterm=NONE
595 | hi Special ctermfg=208 ctermbg=NONE cterm=italic
596 | hi String ctermfg=142 ctermbg=NONE cterm=italic
597 | hi Structure ctermfg=107 ctermbg=NONE cterm=NONE
598 | hi Todo ctermfg=fg ctermbg=234 cterm=bold,italic
599 | hi Type ctermfg=214 ctermbg=NONE cterm=NONE
600 | hi Typedef ctermfg=214 ctermbg=NONE cterm=NONE
601 | hi Underlined ctermfg=109 ctermbg=NONE cterm=underline
602 | hi CursorIM ctermfg=NONE ctermbg=NONE cterm=reverse
603 |
604 | hi Comment cterm=NONE
605 | hi Folded cterm=NONE
606 | hi SpellBad cterm=underline
607 | hi SpellCap cterm=underline
608 | hi SpellLocal cterm=underline
609 | hi SpellRare cterm=underline
610 | hi Special cterm=NONE
611 | hi String cterm=NONE
612 | hi Todo cterm=bold
613 |
614 | hi NormalMode ctermfg=137 ctermbg=234 cterm=reverse
615 | hi InsertMode ctermfg=109 ctermbg=234 cterm=reverse
616 | hi ReplaceMode ctermfg=107 ctermbg=234 cterm=reverse
617 | hi VisualMode ctermfg=208 ctermbg=234 cterm=reverse
618 | hi CommandMode ctermfg=175 ctermbg=234 cterm=reverse
619 | hi Warnings ctermfg=208 ctermbg=234 cterm=reverse
620 | endfunction
621 |
622 | if exists('&termguicolors')
623 | " If we want to use true colors, we must a color scheme which support true
624 | " colors, for example, https://github.com/sickill/vim-monokai
625 | set notermguicolors
626 | endif
627 | set background=dark
628 | colorscheme desert
629 |
630 | " Highlight trailing white spaces and leading tabs
631 | if has('gui_running')
632 | hi Warnings guifg=#ff0000 guibg=yellow
633 | endif
634 |
635 | call matchadd("Warnings", '\s\+$')
636 | call matchadd("Warnings", '^\t\+')
637 |
638 | " statusline settings
639 | let g:currentmode={
640 | \ 'n' : 'NORMAL ',
641 | \ 'v' : 'VISUAL ',
642 | \ 'V' : 'V·Line ',
643 | \ "\" : 'V·Block ',
644 | \ 'i' : 'INSERT ',
645 | \ 'R' : 'R ',
646 | \ 'Rv' : 'V·Replace ',
647 | \ 'c' : 'Command ',
648 | \ 't' : 'TERMINAL'
649 | \}
650 |
651 | set statusline=
652 | set statusline+=%1*
653 | " Show current mode
654 | set statusline+=\ %{toupper(g:currentmode[mode()])}
655 | set statusline+=%{&spell?'[SPELL]':''}
656 |
657 | set statusline+=%#WarningMsg#
658 | set statusline+=%{&paste?'[PASTE]':''}
659 |
660 | set statusline+=%2*
661 | " File path, as typed or relative to current directory
662 | set statusline+=\ %F
663 |
664 | set statusline+=%{&modified?'\ [+]':''}
665 | set statusline+=%{&readonly?'\ []':''}
666 |
667 | " Truncate line here
668 | set statusline+=%<
669 |
670 | " Separation point between left and right aligned items.
671 | set statusline+=%=
672 |
673 | set statusline+=%{&filetype!=#''?&filetype.'\ ':'none\ '}
674 |
675 | " Encoding & Fileformat
676 | set statusline+=%#WarningMsg#
677 | set statusline+=%{&fileencoding!='utf-8'?'['.&fileencoding.']':''}
678 |
679 | set statusline+=%2*
680 | set statusline+=%-7([%{&fileformat}]%)
681 |
682 | " Warning about byte order
683 | set statusline+=%#WarningMsg#
684 | set statusline+=%{&bomb?'[BOM]':''}
685 |
686 | set statusline+=%1*
687 | " Location of cursor line
688 | set statusline+=[%l/%L]
689 |
690 | " Column number
691 | set statusline+=\ col:%2c
692 |
693 | " Warning about trailing spaces.
694 | set statusline+=%#WarningMsg#
695 | set statusline+=%{StatuslineTrailingSpaceWarning()}
696 | set statusline+=%{StatuslineTabWarning()}
697 |
698 | " Recalculate the trailing whitespace warning when idle, and after saving.
699 | augroup check_trailing_space
700 | autocmd!
701 | autocmd CursorHold,BufWritePost * unlet! b:statusline_trailing_space_warning
702 | \ | let &statusline=&statusline
703 | augroup END
704 |
705 | augroup check_mixed_tabs
706 | autocmd!
707 | autocmd CursorHold,BufWritePost * unlet! b:statusline_tab_warning
708 | \ | let &statusline=&statusline
709 | augroup END
710 |
711 | " Find if trailing spaces exist.
712 | function! StatuslineTrailingSpaceWarning()
713 | if !exists('b:statusline_trailing_space_warning')
714 | " If the file is unmodifiable, do not warn this.
715 | if !&modifiable
716 | let b:statusline_trailing_space_warning = ''
717 | return b:statusline_trailing_space_warning
718 | endif
719 |
720 | let l:line_num = search('\s\+$', 'nw')
721 | if l:line_num != 0
722 | let b:statusline_trailing_space_warning = ' [' . l:line_num . ']' . 'trailing space'
723 | else
724 | let b:statusline_trailing_space_warning = ''
725 | endif
726 | endif
727 | return b:statusline_trailing_space_warning
728 | endfunction
729 |
730 | " Find if they are mixed indentings.
731 | function! StatuslineTabWarning()
732 | if !exists('b:statusline_tab_warning')
733 | " If the file is unmodifiable, do not warn this.
734 | if !&modifiable
735 | let b:statusline_trailing_space_warning = ''
736 | return b:statusline_trailing_space_warning
737 | endif
738 |
739 | let has_leading_tabs = search('^\t\+', 'nw') != 0
740 | let has_leading_spaces = search('^ \+', 'nw') != 0
741 |
742 | if has_leading_tabs && has_leading_spaces
743 | let b:statusline_tab_warning = ' [mixed-indenting]'
744 | elseif has_leading_tabs
745 | let b:statusline_tab_warning = ' [tabbed-indenting]'
746 | else
747 | let b:statusline_tab_warning = ''
748 | endif
749 | endif
750 |
751 | return b:statusline_tab_warning
752 | endfunction
753 | "}
754 |
755 | "{ Some good references
756 | " 1. https://gist.github.com/suderman/1243665
757 | " 2. https://gist.github.com/autrimpo/f40e4eda233977dd3a619c6083d9bebd
758 | " 3. https://gist.github.com/romainl/379904f91fa40533175dfaec4c833f2f
759 | "}
760 |
--------------------------------------------------------------------------------
/resources/vim_ui_look.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nvim-zh/minimal_vim/1d0bba61cbacfaacdc87746dc5cb68f8bfc4be28/resources/vim_ui_look.jpg
--------------------------------------------------------------------------------
/vimrc:
--------------------------------------------------------------------------------
1 | init.vim
--------------------------------------------------------------------------------