Personal sane Vim defaults

note, Nov 7, 2023, on Mitja Felicijan's blog

I have found many "sane" default configs on the net and this is my favorite personal list. This is how my .vimrc file looks like.

Updated version is available on GitHub.

" General sane defaults.
syntax enable
colorscheme sorbet
nnoremap q: <nop>
set nocompatible
set relativenumber
set nohlsearch
set smartcase
set ignorecase
set incsearch
set autoindent
set nowrap
set nobackup
set noswapfile
set autoread
set wildmenu
set encoding=utf8
set backspace=2
set scrolloff=4
set spelllang=en_us

" Status Line enhancements.
set laststatus=2
set statusline=%f%m%=%y\ %{strlen(&fenc)?&fenc:'none'}\ %l:%c\ %L\ %P
hi StatusLine cterm=NONE ctermbg=black ctermfg=brown
hi StatusLineNC cterm=NONE ctermbg=black ctermfg=darkgray

" Commenting blocks of code.
augroup commenting_blocks_of_code
  autocmd!
  autocmd FileType c,cpp,go,scala   let b:comment_leader = '// '
  autocmd FileType sh,ruby,python   let b:comment_leader = '# '
  autocmd FileType conf,fstab       let b:comment_leader = '# '
  autocmd FileType lua              let b:comment_leader = '-- '
  autocmd FileType vim              let b:comment_leader = '" '
augroup END
noremap <silent> ,cc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
noremap <silent> ,cu :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>

" Language specific indentation.
filetype plugin indent on
autocmd Filetype make,go,c,cpp setlocal noexpandtab tabstop=4 shiftwidth=4
autocmd Filetype html,js,css setlocal expandtab tabstop=2 shiftwidth=2

I keep it pretty vanilla so this is about everything I have in the file.

Other notes

DateTitle
Sane defaults for tmux with more visible statusbar
Personal sane Vim defaultsvim
Add lazy loading of images in Jekyll posts
Alacritty open links with modifier
Bulk thumbnails
Simple presentations with Markdown
Make B/W SVG charts with matplotlib
My brand new Plan9/9front desktopplan9
Male and female body proportion reference images3d
10/GUI 10 Finger Multitouch User Interface
Cronjobs on Github with Github Actions
Extend Lua with custom C functions using Clangc
Using ffmpeg to combine videos side by side
Aerial photography of algae spotted on river Sava
Display xterm color palette