Gvim vannila vimrc
2 years ago in Plain Text
set fde=getline(v\:lnum)=~'^\"\"'?'>'.(matchend(getline(v\:lnum),'\"\"*')-2)\:'='
set encoding=utf-8
" set UTF-8 encoding
set fenc=utf-8
set termencoding=utf-8
" use indentation of previous line
set autoindent
" use intelligent indentation for C
set smartindent
" configure tabwidth and insert spaces instead of tabs
set tabstop=4 " tab width is 4 spaces
set shiftwidth=4 " indent also with 4 spaces
set expandtab " expand tabs to spaces
" c++
autocmd filetype cpp nnoremap <f9> :w <bar> !g++ -std=c++11 % -o %:r -Wl,--stack,268435456<cr>
autocmd filetype cpp nnoremap <F10> :!%:r<CR>
autocmd filetype cpp nnoremap <C-C> :s/^\(\s*\)/\1\/\/<CR> :s/^\(\s*\)\/\/\/\//\1<CR> $
autocmd filetype cpp nnoremap <f5> :w <bar> !C:\\Borland\\BCC55\Bin\\bcc32 %<cr>
" vim customized shortcut
imap jk <ESC>
if has('gui_running')
set guifont=Source\ Code\ Pro\ for\ Powerline:h15:cANSI
set t_Co=256
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
colorscheme molokai
let g:airline_theme = 'luna'
set cursorline
hi CursorLine cterm=NONE ctermbg=lightyellow
hi CursorColumn cterm=NONE ctermbg=lightyellow
nnoremap c :set cursorline! cursorcolumn!
set lines=22 columns=70
autocmd GUIEnter * set vb t_vb=
endif
:cd F:\code\
" -- bootstrap -----------------------------------------------------------------
set encoding=utf-8 " set vim encoding to UTF-8
set nocompatible " the future is now, use vim defaults instead of vi ones
set nomodeline " disable mode lines (security measure)
set history=1000 " boost commands and search patterns history
set undolevels=1000 " boost undo levels
if exists("+shellslash")
set shellslash " expand filenames with forward slash
endif
set timeoutlen=500 " time in milliseconds for a key sequence to complete
let mapleader="," " change leader key to ,
let maplocalleader="," " change local leader key to ,
" <leader>ev edits .vimrc
nnoremap <leader>ev :vsplit $MYVIMRC<CR>
" <leader>sv sources .vimrc
nnoremap <leader>sv :source $MYVIMRC<CR>:redraw<CR>:echo $MYVIMRC 'reloaded'<CR>
" -- ConEmu integration --------------------------------------------------------
if !empty($CONEMUBUILD)
set term=xterm
set t_Co=256
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
endif
" -- tmux integration ----------------------------------------------------------
" make arrow keys, home/end/pgup/pgdown, and function keys work when inside tmux
if exists('$TMUX') && (system("tmux show-options -wg xterm-keys | cut -d' ' -f2") =~ '^on')
" tmux will send xterm-style keys when its xterm-keys option is on
" add 'setw -g xterm-keys on' to your ~/.tmux.conf
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
execute "set <xHome>=\e[1;*H"
execute "set <xEnd>=\e[1;*F"
execute "set <Insert>=\e[2;*~"
execute "set <Delete>=\e[3;*~"
execute "set <PageUp>=\e[5;*~"
execute "set <PageDown>=\e[6;*~"
execute "set <xF1>=\e[1;*P"
execute "set <xF2>=\e[1;*Q"
execute "set <xF3>=\e[1;*R"
execute "set <xF4>=\e[1;*S"
execute "set <F5>=\e[15;*~"
execute "set <F6>=\e[17;*~"
execute "set <F7>=\e[18;*~"
execute "set <F8>=\e[19;*~"
execute "set <F9>=\e[20;*~"
execute "set <F10>=\e[21;*~"
execute "set <F11>=\e[23;*~"
execute "set <F12>=\e[24;*~"
endif
" -- backup and swap files
" -----------------------------------------------------{
set backup " enable backup files
set writebackup " enable backup files
set swapfile " enable swap files (useful when loading huge files)
let s:vimdir=$HOME . "/.vim"
let &backupdir=s:vimdir . "/backup" " backups location
let &directory=s:vimdir . "/tmp" " swap location
if exists("*mkdir")
if !isdirectory(s:vimdir)
call mkdir(s:vimdir, "p")
endif
if !isdirectory(&backupdir)
call mkdir(&backupdir, "p")
endif
if !isdirectory(&directory)
call mkdir(&directory, "p")
endif
endif
set backupskip+=*.tmp " skip backup for *.tmp
if has("persistent_undo")
let &undodir=&backupdir
set undofile " enable persistent undo
endif
let &viminfo=&viminfo . ",n" . s:vimdir . "/.viminfo" " viminfo location
" -- file type detection -------------------------------------------------------
filetype on " /!\ doesn't play well with compatible mode
filetype plugin on " trigger file type specific plugins
filetype indent on " indent based on file type syntax
" -- command mode --------------------------------------------------------------
set wildmenu " enable tab completion menu
set wildmode=longest:full,full " complete till longest common string, then full
set wildignore+=.git " ignore the .git directory
set wildignore+=*.DS_Store " ignore Mac finder/spotlight crap
if exists ("&wildignorecase")
set wildignorecase
endif
" sudo then write
cabbrev w!! w !sudo tee % >/dev/null
" CTRL+A moves to start of line in command mode
cnoremap <C-a> <home>
" CTRL+E moves to end of line in command mode
cnoremap <C-e> <end>
" CTRL+C closes the command window
if has("autocmd")
augroup command
autocmd!
autocmd CmdwinEnter * noremap <buffer> <silent> <C-c> <ESC>:q<CR>
augroup END
endif
" -- display -------------------------------------------------------------------
set title " change the terminal title
set lazyredraw " do not redraw when executing macros
set report=0 " always report changes
set cursorline " highlight current line
if has("autocmd")
augroup vim
autocmd!
autocmd filetype vim set textwidth=80
augroup END
augroup windows
autocmd!
autocmd VimResized * :wincmd = " resize splits when the window is resized
augroup END
endif
if has("gui_running")
set cursorcolumn " highlight current column
endif
if exists("+relativenumber")
if v:version >= 400
set number
endif
set relativenumber " show relative line numbers
set numberwidth=3 " narrow number column
" cycles between relative / absolute / no numbering
if v:version >= 400
function! RelativeNumberToggle()
if (&number == 1 && &relativenumber == 1)
set nonumber
set relativenumber relativenumber?
elseif (&number == 0 && &relativenumber == 1)
set norelativenumber
set number number?
elseif (&number == 1 && &relativenumber == 0)
set norelativenumber
set nonumber number?
else
set number
set relativenumber relativenumber?
endif
endfunc
else
function! RelativeNumberToggle()
if (&relativenumber == 1)
set number number?
elseif (&number == 1)
set nonumber number?
else
set relativenumber relativenumber?
endif
endfunc
endif
nnoremap <silent> <leader>n :call RelativeNumberToggle()<CR>
else " fallback
set number " show line numbers
" inverts numbering
nnoremap <silent> <leader>n :set number! number?<CR>
endif
set nolist " hide unprintable characters
if has("multi_byte") " if multi_byte is available,
set listchars=eol:¬,tab:▸\ ,trail:⌴ " use pretty Unicode unprintable symbols
else " otherwise,
set listchars=eol:$,tab:>\ ,trail:. " use ASCII characters
endif
" temporarily disable unprintable characters when entering insert mode
if has("autocmd")
augroup list
autocmd!
autocmd InsertEnter * let g:restorelist=&list | :set nolist
autocmd InsertLeave * let &list=g:restorelist
augroup END
endif
" inverts display of unprintable characters
nnoremap <silent> <leader>l :set list! list?<CR>
set noerrorbells " shut up
set visualbell t_vb= " use visual bell instead of error bell
set mousehide " hide mouse pointer when typing
if exists("+showtabline")
set showtabline=1 " only if there are at least two tabs (default)
endif
if has("statusline")
function! StatusLineUTF8()
try
let p = getpos('.')
redir => utf8seq
sil normal! g8
redir End
call setpos('.', p)
return substitute(matchstr(utf8seq, '\x\+ .*\x'), '\<\x\x', '0x\U&', 'g')
catch
return '?'
endtry
endfunction
function! StatusLineFileEncoding()
return has("multi_byte") && strlen(&fenc) ? &fenc : ''
endfunction
function! StatusLineUTF8Bomb()
return has("multi_byte") && &fenc == 'utf-8' && &bomb?'+bomb' : ''
endfunction
function! StatusLineCWD()
let l:pwd = exists('$PWD') ? $PWD : getcwd()
return substitute(fnamemodify(l:pwd, ':~'), '\(\~\?/[^/]*/\).*\(/.\{20\}\)', '\1...\2', '')
endfunction
set laststatus=2 " always show a status line
" set exact status line format
set statusline=
set statusline+=%#Number#
set statusline+=❐\ %02n " buffer number
set statusline+=\ \|\ " separator
set statusline+=%*
set statusline+=%#Identifier#
set statusline+=%f " file path relative to CWD
set statusline+=%*
set statusline+=%#Special#
set statusline+=%m " modified flag
set statusline+=%#Statement#
set statusline+=%r " readonly flag
set statusline+=%h " help buffer flag
set statusline+=%w " preview window flag
set statusline+=%#Type#
set statusline+=[%{&ff}] " file format
set statusline+=[
set statusline+=%{StatusLineFileEncoding()} " file encoding
set statusline+=%#Error#
set statusline+=%{StatusLineUTF8Bomb()} " UTF-8 bomb alert
set statusline+=%#Type#
set statusline+=]
set statusline+=%y " type of file
set statusline+=\ \|\ " separator
set statusline+=%*
set statusline+=%#Directory#
set statusline+=%{StatusLineCWD()} " current working directory
set statusline+=\ " separator
set statusline+=%*
set statusline+=%= " left / right items separator
set statusline+=%#Comment#
set statusline+=%{v:register} " current register in effect
set statusline+=\ " separator
set statusline+=%#Statement#
set statusline+=[U+\%04B] " Unicode code point
set statusline+=[%{StatusLineUTF8()}] " UTF8 sequence
set statusline+=\ \|\ " separator
set statusline+=%#Comment#
set statusline+=line\ %5l/%L\ " line number / number of lines
set statusline+=●\ %02p%%,\ " percentage through file
set statusline+=col\ %3v " column number
endif
set showcmd " show partial command line (default)
set cmdheight=1 " height of the command line
set shortmess=astT " abbreviate messages
set shortmess+=I " disable the welcome screen
if (&t_Co > 2 || has("gui_running")) && has("syntax")
syntax on " turn syntax highlighting on, when terminal has colors or in GUI
endif
if has("gui_running") " GUI mode
set guioptions-=T " remove useless toolbar
set guioptions+=c " prefer console dialogs to popups
endif
" ease reading in GUI mode by inserting space between lines
set linespace=2
if has("folding")
set foldenable " enable folding
set foldmethod=syntax " fold based on syntax highlighting
set foldlevelstart=99 " start editing with all folds open
" filetype settings --- {{{
" Vimscript file settings ---------------------- {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker softtabstop=2 shiftwidth=2 expandtab
augroup END
" }}}
" toggle folds
nnoremap <Space> za
vnoremap <Space> za
set foldtext=FoldText()
function! FoldText()
let l:lpadding = &fdc
redir => l:signs
execute 'silent sign place buffer='.bufnr('%')
redir End
let l:lpadding += l:signs =~ 'id=' ? 2 : 0
if exists("+relativenumber")
if (&number)
let l:lpadding += max([&numberwidth, strlen(line('$'))]) + 1
elseif (&relativenumber)
let l:lpadding += max([&numberwidth, strlen(v:foldstart) + strlen(v:foldstart - line('w0')), strlen(v:foldstart) + strlen(line('w$') - v:foldstart)]) + 1
endif
else
if (&number)
let l:lpadding += max([&numberwidth, strlen(line('$'))]) + 1
endif
endif
" expand tabs
let l:start = substitute(getline(v:foldstart), '\t', repeat(' ', &tabstop), 'g')
let l:end = substitute(substitute(getline(v:foldend), '\t', repeat(' ', &tabstop), 'g'), '^\s*', '', 'g')
let l:info = ' (' . (v:foldend - v:foldstart) . ')'
let l:infolen = strlen(substitute(l:info, '.', 'x', 'g'))
let l:width = winwidth(0) - l:lpadding - l:infolen
let l:separator = ' … '
let l:separatorlen = strlen(substitute(l:separator, '.', 'x', 'g'))
let l:start = strpart(l:start , 0, l:width - strlen(substitute(l:end, '.', 'x', 'g')) - l:separatorlen)
let l:text = l:start . ' … ' . l:end
return l:text . repeat(' ', l:width - strlen(substitute(l:text, ".", "x", "g"))) . l:info
endfunction
endif
" highlight SCM merge conflict markers
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" -- buffers -------------------------------------------------------------------
set nobomb " don't clutter files with Unicode BOMs
set hidden " enable switching between buffers without saving
set switchbuf=usetab " switch to existing tab then window when switching buffer
set autoread " auto read files changed only from the outside of ViM
if has("persistent_undo") && (&undofile)
set autowriteall " auto write changes if persistent undo is enabled
endif
set fsync " sync after write
set confirm " ask whether to save changed files
if has("autocmd")
augroup trailing_spaces
autocmd!
"autocmd BufWritePre * :%s/\s\+$//e " remove trailing spaces before saving
augroup END
augroup restore_cursor
" restore cursor position to last position upon file reopen
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | execute "normal! g`\"" | endif
augroup END
endif
" cd to the directory of the current buffer
nnoremap <silent> <leader>cd :cd %:p:h<CR>
" switch between last two files
nnoremap <leader><Tab> <c-^>
" <leader>w writes the whole buffer to the current file
nnoremap <silent> <leader>w :w!<CR>
inoremap <silent> <leader>w <ESC>:w!<CR>
" <leader>W writes all buffers
nnoremap <silent> <leader>W :wa!<CR>
inoremap <silent> <leader>W <ESC>:wa!<CR>
" -- navigation ----------------------------------------------------------------
" scroll slightly faster
nnoremap <C-e> 2<C-e>
nnoremap <C-y> 2<C-y>
map <C-Up> <C-y>
map <C-Down> <C-e>
set startofline " move to first non-blank of the line when using PageUp/PageDown
" scroll by visual lines, useful when wrapping is enabled
nnoremap j gj
nnoremap <Down> gj
nnoremap k gk
nnoremap <Up> gk
set scrolljump=1 " minimal number of lines to scroll vertically
set scrolloff=4 " number of lines to keep above and below the cursor
" typing zz sets current line at the center of window
set sidescroll=1 " minimal number of columns to scroll horizontally
set sidescrolloff=4 " minimal number of columns to keep around the cursor
if has("vertsplit")
" split current window vertically
nnoremap <leader>_ <C-w>v<C-w>l
set splitright " when splitting vertically, split to the right
endif
if has("windows")
" split current window horizontally
nnoremap <leader>- <C-w>s
set splitbelow " when splitting horizontally, split below
endif
" window navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" move cursor wihout leaving insert mode
try
redir => s:backspace
silent! execute 'set ' 't_kb?'
redir END
if s:backspace !~ '\^H'
inoremap <C-h> <C-o>h
inoremap <C-j> <C-o>j
inoremap <C-k> <C-o>k
inoremap <C-l> <C-o>l
endif
finally
redir END
endtry
" switch between windows by hitting <Tab> twice
nnoremap <silent> <Tab><Tab> <C-w>w
" window resizing
map <S-Left> <C-w><
map <S-Down> <C-w>-
map <S-Up> <C-w>+
map <S-Right> <C-w>>
" <leader>q quits the current window
nnoremap <silent> <leader>q :q<CR>
inoremap <silent> <leader>q <ESC>:q<CR>
" create a new tab
nnoremap <silent> <leader>t :tabnew<CR>
" next/previous buffer navigation
nnoremap <silent> <C-b> :bnext<CR>
nnoremap <silent> <S-b> :bprev<CR>
set whichwrap=b,s,<,> " allow cursor left/right key to wrap to the
" previous/next line
" omit [,] as we use virtual edit in insert mode
" disable arrow keys
" nnoremap <Left> :echo "arrow keys disabled, use h"<CR>
" nnoremap <Right> :echo "arrow keys disabled, use l"<CR>
" nnoremap <Up> :echo "arrow keys disabled, use k"<CR>
" nnoremap <Down> :echo "arrow keys disabled, use j"<CR>
" move to the position where the last change was made
noremap gI `.
" by default, 'a jumps to line marked with ma
" while `a jumps to line AND column marked with ma
" swap ' and `
nnoremap ' `
nnoremap ` '
" -- editing -------------------------------------------------------------------
set showmode " always show the current editing mode
set nowrap " don't wrap lines
set linebreak " yet if enabled break at word boundaries
if has("multi_byte") " if multi_byte is available,
set showbreak=↪ " use pretty Unicode marker
else " otherwise,
set showbreak=> " use ASCII character
endif
set nojoinspaces " insert only one space after '.', '?', '!' when joining lines
set showmatch " briefly jumps the cursor to the matching brace on insert
set matchtime=4 " blink matching braces for 0.4s
set matchpairs+=<:> " make < and > match
runtime macros/matchit.vim " enable extended % matching
set virtualedit=insert " allow the cursor to go everywhere (insert)
set virtualedit+=onemore " allow the cursor to go just past the end of line
set virtualedit+=block " allow the cursor to go everywhere (visual block)
set backspace=indent,eol,start " allow backspacing over everything (insert)
set expandtab " insert spaces instead of tab, CTRL-V+Tab inserts a real tab
set tabstop=2 " 1 tab == 2 spaces
set softtabstop=2 " number of columns used when hitting TAB in insert mode
set smarttab " insert tabs on the start of a line according to shiftwidth
if has("autocmd")
augroup makefile
autocmd!
" don't expand tab to space in Makefiles
autocmd filetype make setlocal noexpandtab
augroup END
endif
set autoindent " enable autoindenting
set copyindent " copy the previous indentation on autoindenting
set shiftwidth=2 " indent with 2 spaces
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
" make Y consistent with C and D by yanking up to end of line
noremap Y y$
" CTRL-S saves file
nnoremap <C-s> :w<CR>
" inverts paste mode
nnoremap <silent> <leader>pp :set paste! paste?<CR>
" same in insert mode
set pastetoggle=<leader>pp
function! Preserve(command)
let l:search=@/
let l:line = line(".")
let l:col = col(".")
execute a:command
let @/=l:search
call cursor(l:line, l:col)
endfunction
" <leader>rt retabs the file, preserve cursor position
nnoremap <silent> <leader>rt :call Preserve(":retab")<CR>
" <leader>s removes trailing spaces
noremap <silent> <leader>s :call Preserve("%s/\\s\\+$//e")<CR>
" <leader>$ fixes mixed EOLs (^M)
noremap <silent> <leader>$ :call Preserve("%s/<C-V><CR>//e")<CR>
" use <leader>d to delete a line without adding it to the yanked stack
nnoremap <silent> <leader>d "_d
vnoremap <silent> <leader>d "_d
" use <leader>c to replace text without yanking replaced text
nnoremap <silent> <leader>c "_c
vnoremap <silent> <leader>c "_c
" yank/paste to/from the OS clipboard
noremap <silent> <leader>y "+y
noremap <silent> <leader>Y "+Y
noremap <silent> <leader>p "+p
noremap <silent> <leader>P "+P
" paste without yanking replaced text in visual mode
vnoremap <silent> p "_dP
vnoremap <silent> P "_dp
" always share the OS clipboard
set clipboard+=unnamed
" autofix typos
iabbrev teh the
" reselect last selection after indent / un-indent in visual and select modes
vnoremap < <gv
vnoremap > >gv
vmap <Tab> >
vmap <S-Tab> <
set cpoptions+=$ " display $ at the end of the replacement zone instead of
" deleting text with 'cw' and alike
set formatoptions-=t " don't auto-wrap text using textwidth
set formatoptions+=c " auto-wrap comments using textwidth
set formatoptions+=r " auto-insert current comment leader, C-u to undo
" exit from insert mode without cursor movement
inoremap jk <ESC>`^
" quick insertion of newline in normal mode with <CR>
if has("autocmd")
nnoremap <silent> <CR> :put=''<CR>
augroup newline
autocmd!
autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>
autocmd CmdwinEnter * nnoremap <buffer> <CR> <CR>
augroup END
endif
" remap U to <C-r> for easier redo
nnoremap U <C-r>
" preserve cursor position when joining lines
nnoremap J :call Preserve("normal! J")<CR>
" split line and preserve cursor position
nnoremap S :call Preserve("normal! i\r")<CR>
" select what was just pasted
nnoremap <leader>v V`]
" <C-Space> triggers completion in insert mode
inoremap <C-Space> <C-P>
if !has("gui_running")
inoremap <C-@> <C-P>
endif
set completeopt=longest,menuone,preview " better completion
" move current line down
noremap <silent>- :m+<CR>
" move current line up
noremap <silent>_ :m-2<CR>
" move visual selection down
vnoremap <silent>- :m '>+1<CR>gv=gv
" move visual selection up
vnoremap <silent>_ :m '<-2<CR>gv=gv
" change cursor to vertical bar in insert mode when using iTerm2
if $TERM_PROGRAM == 'iTerm.app'
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
endif
nnoremap Q <NOP>
" make dot work in visual mode
vnoremap . :normal .<CR>
" make v enter blockwise visual mode, and CTRL-V enter visual mode
nnoremap v <C-V>
nnoremap <C-V> v
vnoremap v <C-V>
vnoremap <C-V> v
" -- searching -----------------------------------------------------------------
set wrapscan " wrap around when searching
set incsearch " show match results while typing search pattern
if (&t_Co > 2 || has("gui_running"))
set hlsearch " highlight search terms
endif
" temporarily disable highlighting when entering insert mode
if has("autocmd")
augroup hlsearch
autocmd!
autocmd InsertEnter * let g:restorehlsearch=&hlsearch | :set nohlsearch
autocmd InsertLeave * let &hlsearch=g:restorehlsearch
augroup END
endif
set ignorecase " case insensitive search
set smartcase " case insensitive only if search pattern is all lowercase
" (smartcase requires ignorecase)
set gdefault " search/replace globally (on a line) by default
" temporarily disable search highlighting
nnoremap <silent> <leader><Space> :nohlsearch<CR>:match none<CR>:2match none<CR>:3match none<CR>
" highlight all instances of the current word where thecursor is positioned
nnoremap <silent> <leader>hs :setl hls<CR>:let @/="\\<<C-r><C-w>\\>"<CR>
" use <leader>h1, <leader>h2, <leader>h3 to highlight words in different colors
nnoremap <silent> <leader>h1 :highlight Highlight1 ctermfg=0 ctermbg=226 guifg=Black guibg=Yellow<CR> :execute 'match Highlight1 /\<<C-r><C-w>\>/'<cr>
nnoremap <silent> <leader>h2 :highlight Highlight2 ctermfg=0 ctermbg=51 guifg=Black guibg=Cyan<CR> :execute '2match Highlight2 /\<<C-r><C-w>\>/'<cr>
nnoremap <silent> <leader>h3 :highlight Highlight3 ctermfg=0 ctermbg=46 guifg=Black guibg=Green<CR> :execute '3match Highlight3 /\<<C-r><C-w>\>/'<cr>
" very magic search patterns
" everything but '0'-'9', 'a'-'z', 'A'-'Z' and '_' has a special meaning
"nnoremap / /\v
"vnoremap / /\v
"nnoremap ? ?\v
"vnoremap ? ?\v
"cnoremap %s/ %s/\v
" replace word under cursor
nnoremap <leader>; :%s/\<<C-r><C-w>\>//<Left>
function! BlinkMatch(t)
let [l:bufnum, l:lnum, l:col, l:off] = getpos('.')
let l:current = '\c\%#'.@/
let l:highlight = matchadd('IncSearch', l:current, 1000)
redraw
exec 'sleep ' . float2nr(a:t * 1000) . 'm'
call matchdelete(l:highlight)
redraw
endfunction
" center screen on next/previous match, blink current match
noremap <silent> n nzzzv:call BlinkMatch(0.2)<CR>
noremap <silent> N Nzzzv:call BlinkMatch(0.2)<CR>
function! GetVisualSelection()
let [l:l1, l:c1] = getpos("'<")[1:2]
let [l:l2, l:c2] = getpos("'>")[1:2]
let l:selection = getline(l:l1, l:l2)
let l:selection[-1] = l:selection[-1][: l:c2 - 1]
let l:selection[0] = l:selection[0][l:c1 - 1:]
return join(l:selection, "\n")
endfunction
" search for visually selected areas
xnoremap * <ESC>/<C-r>=substitute(escape(GetVisualSelection(), '\/.*$^~[]'), "\n", '\\n', "g")<CR><CR>
xnoremap # <ESC>?<C-r>=substitute(escape(GetVisualSelection(), '\/.*$^~[]'), "\n", '\\n', "g")<CR><CR>
" prepare search based on visually selected area
xnoremap / <ESC>/<C-r>=substitute(escape(GetVisualSelection(), '\/.*$^~[]'), "\n", '\\n', "g")<CR>
" prepare substitution based on visually selected area
xnoremap & <ESC>:%s/<C-r>=substitute(escape(GetVisualSelection(), '\/.*$^~[]'), "\n", '\\n', "g")<CR>/
" -- spell checking ------------------------------------------------------------
set spelllang=en " English only
set nospell " disabled by default
if has("autocmd")
augroup spell
autocmd!
"autocmd filetype vim setlocal spell " enabled when editing .vimrc
augroup END
endif
" FINDING FILES:
" Search down into subfolders
" Provides tab-completion for all file-related tasks
set path+=**
" Display all matching files when we tab complete
set wildmenu
" NOW WE CAN:
" - Hit tab to :find by partial match
" - Use * to make it fuzzy
" THINGS TO CONSIDER:
" - :b lets you autocomplete any open buffer
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838