syntax on
colorscheme murphy
set textwidth=72
set tabstop=4
set shiftwidth=0
set expandtab
set autoindent
set number
set hlsearch
set incsearch
set showcmd
set hidden
set ruler
set autochdir
set nojoinspaces
set wildmenu
set listchars=eol:$,tab:>-,nbsp:~,trail:~
set guioptions=ic
autocmd BufNewFile,BufRead *.md set filetype=markdown
autocmd BufNewFile,BufRead *.html,*.css,*.js,*.json,*.yml,*.yaml setlocal tabstop=2
autocmd BufNewFile,BufRead *.go,Makefile* setlocal tabstop=8 noexpandtab
autocmd BufWinEnter * syntax keyword Todo TODO
autocmd BufWinEnter * syntax match Error /\s\+$/
My ~/.vimrc on my home system that I use for day-to-day activities is a little larger. Here is a copy of it: github.com/susam/dotfiles - vimrc.
On similar lines, I recently shared a small 50 line ~/.emacs helpful for quickly setting up a Common Lisp development environment here: github.com/susam/emacs4cl.
It’s worse for me. At this point I get distracted by the highlighting. $work has a custom IDE, and ny first month there I found out how to turn off the highlighting.
Brains and eyes are different. I’m partially blind so I need every single variation and hint I can get, and you get distracted. That’s why there’s a whole universe of tools and options :)
I had to do the same thing for an algorithmics exam at university, I came up with
""" Condensed vimrc for exams
syntax on
set ai ts=4 sw=4 et nowrap number relativenumber hlsearch incsearch
color darkblue
The problems were ACM-style competitive programming problems, and had to be solved in C++. You could use whatever was preinstalled in their custom Fedora exam environment (they even had Eclipse and VSCode, however many students complained that they were atrociously slow on the thin clients we had). I also remember my C++ template:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
while (n-- > 0) { tc(); }
}
Not sure I would recommend turning off swap files. It happens to me not infrequently that there is a crash while I’m editing code. Swap files are also useful as a signal when a file is opened by a Vim in the background but you accidentally open it again in another Vim instance. With swap files enabled you would get a nasty warning that a swap file already exists. Not sure what would happen in that case if swap files are disabled.
I have a bad habit of backgrounding vim instances with unsaved state, so I’m really happy with the swap files for when I forget they’re there and reboot (or someone else reboots a shared machine). I’m also really happy with vim’s persistent undo. I have this in my vimrc:
set dir=${XDG_CACHE_HOME}/vim/swap//
set backupdir=${XDG_CACHE_HOME}/vim/backup//
set undodir=${XDG_CACHE_HOME}/vim/undo//
set undofile
set undolevels=1000
set undoreload=10000
This means that if I kill a vim session (even with kill -9 or a hard reboot), I can generally recover exactly where I was and even if I just deleted a load of stuff and then saved, I can bring it back by hitting u.
To set it up, I would run vim ~/.vimrc, manually enter those 5 lines in whichever order that I remembered them, then quit and restart Vim to pick up the new configurations.
You should be able to run :source % to get all of those without having to restart vim first!
If you like set incsearch and use neovim, you may also like set inccommand=nosplit.
Funny enough too how emacs evil mode sort of defaults to a lot of these properties out of the box as well. In terms of case insensitivity I prefer rebinding search with something like noremap / /\v\c so I can delete the flags instead of toggling them after typing /
I usually put these 23 lines in a blank
~/.vimrc
:My
~/.vimrc
on my home system that I use for day-to-day activities is a little larger. Here is a copy of it: github.com/susam/dotfiles - vimrc.On similar lines, I recently shared a small 50 line
~/.emacs
helpful for quickly setting up a Common Lisp development environment here: github.com/susam/emacs4cl.+1 for syntax on. I know “I don’t NEED syntax highlighting” is the new cool thing to do, but I need every bit of help I can get disambiguating syntax!
Also wow I didn’t know about wildmenu. Thanks for that!
It’s worse for me. At this point I get distracted by the highlighting. $work has a custom IDE, and ny first month there I found out how to turn off the highlighting.
Brains and eyes are different. I’m partially blind so I need every single variation and hint I can get, and you get distracted. That’s why there’s a whole universe of tools and options :)
smartcase
is IMHO better thanignorecase
numbers
slow Vim, I preferruler
as is less obstructivesmartcase
and I do not like line 4I had to do the same thing for an algorithmics exam at university, I came up with
The problems were ACM-style competitive programming problems, and had to be solved in C++. You could use whatever was preinstalled in their custom Fedora exam environment (they even had Eclipse and VSCode, however many students complained that they were atrociously slow on the thin clients we had). I also remember my C++ template:
Not sure I would recommend turning off swap files. It happens to me not infrequently that there is a crash while I’m editing code. Swap files are also useful as a signal when a file is opened by a Vim in the background but you accidentally open it again in another Vim instance. With swap files enabled you would get a nasty warning that a swap file already exists. Not sure what would happen in that case if swap files are disabled.
I have a bad habit of backgrounding vim instances with unsaved state, so I’m really happy with the swap files for when I forget they’re there and reboot (or someone else reboots a shared machine). I’m also really happy with vim’s persistent undo. I have this in my vimrc:
This means that if I kill a vim session (even with
kill -9
or a hard reboot), I can generally recover exactly where I was and even if I just deleted a load of stuff and then saved, I can bring it back by hittingu
.Neat! I was unaware of persistent undo. Going to add this now! :)
You should be able to run
:source %
to get all of those without having to restart vim first!If you like
set incsearch
and use neovim, you may also likeset inccommand=nosplit
. Funny enough too how emacs evil mode sort of defaults to a lot of these properties out of the box as well. In terms of case insensitivity I prefer rebinding search with something likenoremap / /\v\c
so I can delete the flags instead of toggling them after typing /highlighted, incremental search? so gross
I use this:
Explained at http://leahneukirchen.org/blog/archive/2020/05/a-minimal-vimrc.html