From 846c204094efcf1bcef432ed2c8214eb5c1b3b4a Mon Sep 17 00:00:00 2001 From: Thomas Preisner Date: Wed, 22 Sep 2021 15:54:42 +0200 Subject: [PATCH] config: nvim: rework basic configuration --- config/nvim/init.vim | 52 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/config/nvim/init.vim b/config/nvim/init.vim index a03ec52..30d53aa 100644 --- a/config/nvim/init.vim +++ b/config/nvim/init.vim @@ -1,6 +1,4 @@ -" .vimrc - -" only vim and not vi +" drop vi-compatibility set nocompatible " disable autocmd set secure @@ -66,6 +64,9 @@ set smartcase " highlight all matches. use to remove the highlights set hlsearch +" treat hyphenated words as a single word +set iskeyword+=- + " syntax folding if has('folding') set foldmethod=syntax @@ -115,29 +116,56 @@ highlight ColorColumn ctermbg=235 guibg=#2d2d2d " display line numbers set number +" show cursor position all the time +set ruler + +" show tabs all the time +set showtabline=2 + " show currently typed command set showcmd " define characters to display when using 'set list' set listchars=tab:→\ ,trail:∙,eol:¬,extends:❯,precedes:❮,nbsp:␣ -" Disable arrow keys -"map -"map -"map -"map +" increase completion performance and reduce time until timeout +set updatetime=300 +set timeoutlen=500 -"map! -"map! -"map! -"map! +" copy paste between vim and everything else +" TODO: check whether the 'plus' suffix works with plain vim +set clipboard=unnamedplus +" Keybindings " allow easier pane switching nnoremap nnoremap nnoremap nnoremap +" allow easier pane resizing +nnoremap :resize -2 +nnoremap :resize +2 +nnoremap :vertical resize -2 +nnoremap :vertical resize +2 + +" use TAB to switch to next buffers +nnoremap :bnext +" use Shift-TAB to switch to previous buffers +nnoremap :bprevious + +" use TAB for skipping through completion options +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" + " Misc set mouse=n + +" remove windows ^M when the encoding gets messed up noremap m mmHmt:%s///ge'tzt'm + +" autoreload vimrc when writing init.vim +au! BufWritePost $MYVIMRC source % + +" add convenience command for force-saving read-only files +cmap w!! w !sudo tee %