From: sev Date: Fri, 18 Oct 2024 22:00:39 +0000 (-0500) Subject: vimrc: update comments, add mappings X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/commitdiff_plain/b3b2323450b34ca2b64af10261e1bb9456b5f819 vimrc: update comments, add mappings also move autoindent to vim-only as nvim enables by default --- diff --git a/etc/vim/.vimrc b/etc/vim/.vimrc index 799bd97..165d01f 100644 --- a/etc/vim/.vimrc +++ b/etc/vim/.vimrc @@ -1,25 +1,29 @@ -" use our new vim dir primarily +""" vim dir in xdg config let x = ($XDG_CONFIG_HOME??($HOME.'/.config')).'/vim' execute 'set runtimepath='.x.','.&runtimepath.','.x.'/after' execute 'set packpath='.x.','.&packpath.','.x.'/after' +""" vim-only defaults if !has('nvim') - " neovim doesn't have defaults to load explicitly + " neovim defaults are already set source $VIMRUNTIME/defaults.vim - " neovim does this stuff already + " packages packadd matchit packadd editorconfig + " options + set hlsearch set autoindent endif -" define and create a centralized dir to keep transient state files in +""" dir for state files in xdg state let x = ($XDG_STATE_HOME??($HOME.'/.local/state')).'/vim' if !isdirectory(x) call mkdir(x, 'p', 0700) endif +" NOTE: backup files in vim state dir for both vim and neovim let y = x.'/backup' if !isdirectory(y) call mkdir(y, 'p', 0700) @@ -27,7 +31,6 @@ endif execute 'set backupdir='.y.'//' set backup backupcopy=yes - " NOTE: neovim uses ShaDa (SHAred DAta) format for viminfo and swap, and uses a " different version for undo files, so these types of files when created " by vim cannot be used with neovim, and the 'viminfofile', 'directory', @@ -56,7 +59,8 @@ autocmd BufNew * set undofile unlet x unlet y -" options + +""" options autocmd VimEnter,WinNew * set number autocmd VimEnter,WinNew * set relativenumber autocmd InsertEnter * set norelativenumber @@ -66,12 +70,11 @@ autocmd FocusGained * set relativenumber autocmd VimEnter,WinNew * set colorcolumn=80 autocmd VimEnter,WinNew * set cursorline -set hlsearch autocmd VimEnter,WinNew * set list set listchars=tab:├─,extends:»,precedes:«,space:·,trail:∙,nbsp:■ -" styles +""" styles highlight ColorColumn term=NONE ctermbg=0 highlight WhiteSpaceMol ctermfg=Black @@ -79,7 +82,7 @@ autocmd VimEnter,WinNew * match WhiteSpaceMol / / highlight WhiteSpaceBol ctermfg=DarkBlue autocmd VimEnter,WinNew * 2match WhiteSpaceBol /\(^ \+\)\|\( \+$\)/ -" indent +""" indent autocmd FileType python set softtabstop=4 shiftwidth=4 expandtab autocmd FileType markdown set softtabstop=4 shiftwidth=4 expandtab autocmd FileType javascript set softtabstop=2 shiftwidth=2 expandtab @@ -87,5 +90,31 @@ autocmd FileType json set softtabstop=2 shiftwidth=2 expandtab autocmd FileType html set softtabstop=2 shiftwidth=2 expandtab let g:EditorConfig_enable_for_new_buf = 1 -" syntax +""" syntax autocmd FileType todo set colorcolumn=0 + +""" mappings +"" use more accessible escapes, as C-n and C-o are shadowed by some terminals +if has('nvim') + tnoremap n + tnoremap o +endif + +"" move windows any time +if has('nvim') + " terminal + tnoremap h + tnoremap j + tnoremap k + tnoremap l +endif +" insert +inoremap h +inoremap j +inoremap k +inoremap l +" normal +nnoremap h +nnoremap j +nnoremap k +nnoremap l