config: nvim: rework basic configuration

This commit is contained in:
Thomas Preisner 2021-09-22 15:54:42 +02:00
parent ef82f3b11f
commit 846c204094

View file

@ -1,6 +1,4 @@
" .vimrc " drop vi-compatibility
" only vim and not vi
set nocompatible set nocompatible
" disable autocmd " disable autocmd
set secure set secure
@ -66,6 +64,9 @@ set smartcase
" highlight all matches. use <C-L> to remove the highlights " highlight all matches. use <C-L> to remove the highlights
set hlsearch set hlsearch
" treat hyphenated words as a single word
set iskeyword+=-
" syntax folding " syntax folding
if has('folding') if has('folding')
set foldmethod=syntax set foldmethod=syntax
@ -115,29 +116,56 @@ highlight ColorColumn ctermbg=235 guibg=#2d2d2d
" display line numbers " display line numbers
set number set number
" show cursor position all the time
set ruler
" show tabs all the time
set showtabline=2
" show currently typed command " show currently typed command
set showcmd set showcmd
" define characters to display when using 'set list' " define characters to display when using 'set list'
set listchars=tab:→\ ,trail:∙,eol,extends:,precedes:,nbsp:␣ set listchars=tab:→\ ,trail:∙,eol,extends:,precedes:,nbsp:␣
" Disable arrow keys " increase completion performance and reduce time until timeout
"map <Right> <Nop> set updatetime=300
"map <Left> <Nop> set timeoutlen=500
"map <Up> <Nop>
"map <Down> <Nop>
"map! <Right> <Nop> " copy paste between vim and everything else
"map! <Left> <Nop> " TODO: check whether the 'plus' suffix works with plain vim
"map! <Up> <Nop> set clipboard=unnamedplus
"map! <Down> <Nop>
" Keybindings
" allow easier pane switching " allow easier pane switching
nnoremap <C-J> <C-W><C-J> nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K> nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L> nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H> nnoremap <C-H> <C-W><C-H>
" allow easier pane resizing
nnoremap <M-J> :resize -2<CR>
nnoremap <M-K> :resize +2<CR>
nnoremap <M-L> :vertical resize -2<CR>
nnoremap <M-H> :vertical resize +2<CR>
" use TAB to switch to next buffers
nnoremap <TAB> :bnext<CR>
" use Shift-TAB to switch to previous buffers
nnoremap <S-TAB> :bprevious<CR>
" use TAB for skipping through completion options
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
" Misc " Misc
set mouse=n set mouse=n
" remove windows ^M when the encoding gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'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 %