" NOTE: This .vimrc is minimal and not well-maintained because I have migrated " from Vim to Neovim. set encoding=utf-8 scriptencoding utf-8 if empty($XDG_DATA_HOME) let s:data_home = $HOME . '/.local/share' else let s:data_home = $XDG_DATA_HOME endif let s:my_env = { \ 'backup_dir': s:data_home . '/vim/backup', \ 'swap_dir': s:data_home . '/vim/swap', \ 'undo_dir': s:data_home . '/vim/undo', \ 'viminfo': s:data_home . '/vim/viminfo', \ } for [s:k, s:v] in items(s:my_env) if s:k =~# '_dir$' && !isdirectory(s:v) call mkdir(s:v, 'p') endif endfor unlet s:k s:v s:data_home language messages C language time C syntax on filetype plugin indent on set nowrapscan set incsearch set ignorecase set smartcase set scrolloff=7 set wrap set linebreak set breakindent set breakindentopt+=sbr let &showbreak = '> ' set sidescrolloff=20 set display=lastline let &fillchars = 'vert: ,fold: ,diff: ' set list let &listchars = "eol: ,tab:> ,trail:^,extends:>,precedes:<" set concealcursor=cnv set synmaxcol=500 set hlsearch set t_Co=256 set colorcolumn=+1 set laststatus=2 set winminheight=0 set hidden set switchbuf=usetab set showtabline=1 set notitle set mouse= set shortmess+=a set shortmess+=s set shortmess+=I set shortmess+=c set showcmd set noshowmode set report=999 set confirm set belloff=all set clipboard=unnamed set undofile let &undodir = s:my_env.undo_dir set textwidth=0 set backspace=indent,eol,start set completeopt-=preview set pumheight=10 set noshowmatch set matchpairs+=<:> set nojoinspaces set nrformats-=octal if has('patch-8.2.0860') set nrformats+=unsigned endif set tabstop=4 set shiftwidth=4 set smarttab set softtabstop=4 set expandtab set autoindent set smartindent set copyindent set preserveindent set foldlevelstart=0 set foldopen+=insert set foldmethod=marker set diffopt+=vertical set diffopt+=foldcolumn:3 set maxmapdepth=10 set notimeout set ttimeout set ttimeoutlen=100 set nofixendofline set fileformats=unix,dos set backup let &backupdir = s:my_env.backup_dir set autowrite set autoread let &directory = s:my_env.swap_dir . '//' set history=2000 set wildignore+=*.o,*.obj,*.lib set wildignorecase set wildmenu set shell=zsh set keywordprg= set fileencodings=utf-8,cp932,euc-jp set sessionoptions+=localoptions set sessionoptions+=resize set sessionoptions+=winpos let &viminfofile = s:my_env.viminfo augroup Vimrc autocmd! augroup END autocmd Vimrc VimResized * wincmd = autocmd Vimrc BufRead * \ if 0 < line("'\"") && line("'\"") <= line('$') && \ &filetype !~# 'commit' && &filetype !~# 'rebase' | \ execute "normal g`\"" | \ endif if has('patch-9.0.1799') packadd editorconfig function! SetIsEditorConfigApplied(config) let b:__editorconfig__ = {} if has_key(a:config, 'indent_style') let b:__editorconfig__.expandtab = 1 endif if has_key(a:config, 'tab_width') let b:__editorconfig__.tabstop = 1 endif if has_key(a:config, 'indent_size') let b:__editorconfig__.shiftwidth = 1 let b:__editorconfig__.softtabstop = 1 endif return 0 endfunction call editorconfig#AddNewHook(function('SetIsEditorConfigApplied')) endif function! SetIndentStyle(prefer_spaces, indent_size) let editorconfig = get(b:, '__editorconfig__', {}) if !has_key(editorconfig, 'expandtab') let &expandtab = a:prefer_spaces endif if !has_key(editorconfig, 'tabstop') let &tabstop = a:indent_size endif if !has_key(editorconfig, 'shiftwidth') let &shiftwidth = a:indent_size endif if !has_key(editorconfig, 'softtabstop') let &softtabstop = a:indent_size endif endfunction autocmd Vimrc FileType c call SetIndentStyle(1, 4) autocmd Vimrc FileType cmake call SetIndentStyle(1, 2) autocmd Vimrc FileType cpp call SetIndentStyle(1, 4) autocmd Vimrc FileType css call SetIndentStyle(1, 2) autocmd Vimrc FileType docbk call SetIndentStyle(1, 2) autocmd Vimrc FileType go call SetIndentStyle(1, 4) autocmd Vimrc FileType haskell call SetIndentStyle(1, 4) autocmd Vimrc FileType html call SetIndentStyle(1, 2) autocmd Vimrc FileType javascript call SetIndentStyle(1, 2) autocmd Vimrc FileType javascriptreact call SetIndentStyle(1, 2) autocmd Vimrc FileType json call SetIndentStyle(1, 2) autocmd Vimrc FileType leaf call SetIndentStyle(1, 4) autocmd Vimrc FileType lisp call SetIndentStyle(1, 2) autocmd Vimrc FileType lua call SetIndentStyle(1, 3) autocmd Vimrc FileType markdown call SetIndentStyle(1, 4) autocmd Vimrc FileType nix call SetIndentStyle(1, 2) autocmd Vimrc FileType php call SetIndentStyle(1, 2) autocmd Vimrc FileType python call SetIndentStyle(1, 4) autocmd Vimrc FileType ruby call SetIndentStyle(1, 2) autocmd Vimrc FileType satysfi call SetIndentStyle(1, 2) autocmd Vimrc FileType sbt call SetIndentStyle(1, 2) autocmd Vimrc FileType scala call SetIndentStyle(1, 2) autocmd Vimrc FileType toml call SetIndentStyle(1, 2) autocmd Vimrc FileType typescript call SetIndentStyle(1, 2) autocmd Vimrc FileType typescriptreact call SetIndentStyle(1, 2) autocmd Vimrc FileType vim call SetIndentStyle(1, 4) autocmd Vimrc FileType xml call SetIndentStyle(1, 2) autocmd Vimrc FileType yaml call SetIndentStyle(1, 2) noremap gn v:searchforward ? 'gn' : 'gN' noremap gN v:searchforward ? 'gN' : 'gn' noremap n v:searchforward ? 'n' : 'N' noremap N v:searchforward ? 'N' : 'n' nnoremap & :%&& xnoremap & :%&& nnoremap " xnoremap " let @j = 'j.' let @k = 'k.' let @n = 'n.' let @m = 'N.' nnoremap @N @m nnoremap @a 9999@@ nnoremap ` @@ inoremap inoremap U inoremap U inoremap u inoremap u cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap inoremap cnoremap inoremap nnoremap c "_c xnoremap c "_c nnoremap C "_C xnoremap C "_C noremap g= = noremap ml gu noremap mu gU noremap gu noremap gU xnoremap u xnoremap U xnoremap x "_x nnoremap Y y$ xnoremap Y mode() ==# 'V' ? 'y' : 'Vy' nnoremap R gR nnoremap gR R nnoremap r gr nnoremap gr r nnoremap U noremap H ^ noremap L $ noremap M % noremap gw b noremap gW B noremap k gk noremap j gj noremap gk k noremap gj j nnoremap gff gF nnoremap tt :tabnew nnoremap tn :=(tabpagenr() + v:count1 - 1) % tabpagenr('$') + 1tabnext nnoremap tp :=(tabpagenr('$') * 10 + tabpagenr() - v:count1 - 1) % tabpagenr('$') + 1tabnext nnoremap tN :tabmove + nnoremap tP :tabmove - nnoremap tsh :leftabove vsplit nnoremap tsj :rightbelow split nnoremap tsk :leftabove split nnoremap tsl :rightbelow vsplit nnoremap tsH :topleft vsplit nnoremap tsJ :botright split nnoremap tsK :topleft split nnoremap tsL :botright vsplit nnoremap twh :leftabove vnew nnoremap twj :rightbelow new nnoremap twk :leftabove new nnoremap twl :rightbelow vnew nnoremap twH :topleft vnew nnoremap twJ :botright new nnoremap twK :topleft new nnoremap twL :botright vnew nnoremap th h nnoremap tj j nnoremap tk k nnoremap tl l nnoremap tH H nnoremap tJ J nnoremap tK K nnoremap tL L nnoremap tx x nnoremap tRH _ nnoremap tRW nnoremap tRR _ nnoremap t= = nnoremap tq :bdelete nnoremap tc c nnoremap to o nnoremap tO :tabonly nnoremap T nnoremap Tb :if &background == 'dark' set background=light else set background=dark endif nnoremap Tc :set cursorcolumn! set cursorline! nnoremap Td :if &diff diffoff else diffthis endif nnoremap Te :set expandtab! nnoremap Th :set hlsearch! nnoremap Tn :set number! nnoremap Ts :set spell! nnoremap T8 :if &textwidth ==# 80 set textwidth=0 else set textwidth=80 endif nnoremap T0 :if &textwidth ==# 100 set textwidth=0 else set textwidth=100 endif nnoremap T2 :if &textwidth ==# 120 set textwidth=0 else set textwidth=120 endif nnoremap Tw :set wrap! nmap TB Tb nmap TC Tc nmap TD Td nmap TE Te nmap TH Th nmap TN Tn nmap TS Ts nmap TW Tw nnoremap gh nnoremap gH nnoremap g nnoremap Q nnoremap gQ nnoremap ZZ nnoremap ZQ nnoremap :help onoremap gv :normal! gv nnoremap ; : nnoremap : ; xnoremap ; : xnoremap : ; nnoremap @; @: xnoremap @; @: cnoremap ; : inoremap ; : imap jk cmap jk nnoremap :nohlsearch nnoremap w :update nnoremap Z :wqall inoreabbrev TOOD TODO inoreabbrev retrun return inoreabbrev reutrn return inoreabbrev tihs this cnoreabbrev S %s set background=dark colorscheme desert let &statusline = ' %f %r %m %= %l/%L %{&fileencoding} %{&fileformat} %y '