From 44298787046a809e70d151aa5df1d6322070fcce Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Tue, 24 Jan 2023 14:52:36 -0800 Subject: [PATCH] Bring some vimrc defaults into user vimrc file This should result in a notably more consistent experience across platforms. --- src/.vimrc | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/.vimrc b/src/.vimrc index f01157a..961d922 100644 --- a/src/.vimrc +++ b/src/.vimrc @@ -7,9 +7,26 @@ endif " Get the defaults that most users want source $VIMRUNTIME/defaults.vim +" Use Vim settings rather than Vi settings +" This is run early to avoid clobbering other options as a side effect. +if &compatible + set nocompatible +endif + +" This achieves the same as above iff +eval feature is missing. +silent! while 0 + set nocompatible +silent! endwhile + " Don't keep context lines around cursor set scrolloff=0 +set history=50 " keep 50 lines of command line history +set ruler " show cursor position at all times +set showcmd " display incomplete commands +set wildmenu " display completion matches in a status line +set display=truncate " show @@@ in the last line if it is truncated + " do not keep backup files or undo files (they clutter filesystem) set nobackup set noundofile @@ -32,6 +49,11 @@ if has('syntax') && has('eval') packadd! matchit endif +" Perform incremental searching when it's possible to timeout +if has('reltime') + set incsearch +endif + " Enable re-use of the same window to switch from an unsaved buffer without " saving it first. Also allows you to keep an undo history for multiple files " when re-using the same window in this way. @@ -83,6 +105,21 @@ set pastetoggle= " Use one tab when using Vim shifts set tabstop=4 softtabstop=0 noexpandtab shiftwidth=4 +" Allow backspace to go over everything in insert mode +set backspace=indent,eol,start + +" In many terminal emulators the mouse works just fine. By enabling it you can +" position the cursor, Visually select and scroll with the mouse. +" Only xterm can grab the mouse events when using the shift key, for other +" terminals use ":", select text, and press Esc. +if has('mouse') + if &term =~ 'xterm' + set mouse=a + else + set mouse=nvi + endif +endif + " Jump to last position when reopening a file if has('autocmd') au BufReadPost * if line ("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif @@ -92,3 +129,21 @@ endif " Map (redraw screen) to also turn off search highlighting until the " next search nnoremap :nohl + +" Execute only if Vim is compiled with +eval +if 1 + " Enable file type detection. + " Use the default filetype settings, so that mail gets 'tw' set to 72, + " 'cindent' is on in C files, etc. + " Also load indent files to automatically do laugnage-dependent indenting. + " Revert with ":filetype off". + filetype plugin indent on +endif + +" Convenient command to see the difference between the current buffer and the +" file it was loaded from, thus the changes you made. +" Revert with ":delcommand DiffOrig". +if !exists(":DiffOrig") + command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis + \ | wincmd p | diffthis +endif