Skip to content

Instantly share code, notes, and snippets.

@NickCrew
Created January 16, 2025 18:51
Show Gist options
  • Save NickCrew/f61b31f66fe7bc79fd880a03c3177c3f to your computer and use it in GitHub Desktop.
Save NickCrew/f61b31f66fe7bc79fd880a03c3177c3f to your computer and use it in GitHub Desktop.
Minimal Vimrc with Sane defaults to carry from host to host
""""""""""""""""""""""""""""""""""""""""""
"
" Minimal Sane Defaults for Classic Vim
"
""""""""""""""""""""""""""""""""""""""""""
set nocompatible
syntax on
filetype on
filetype indent on
filetype plugin on
filetype plugin indent on
set backspace=indent,eol,start
set foldmethod=indent
set mouse=a " enable mouse support
set scrolloff=7 " always keep the cursor 7 lines below/above the top/bottom of the window
set encoding=utf-8
set number
set ruler
set autoread
set hidden " switch buffers without saving
set noswapfile " i hate swapfiles
set undofile " enable undo history
set undodir=~/.vim/undo
set undolevels=10000 " numbers of particular undos to save
set undoreload=100000 " number of undo lines to save
set backupdir=~/vim/backup " enable backupets
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir))
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir))
endif
""""""""""""
" Completion
""""""""""""
set complete+=d
set completeopt=longest,menuone
" Enable wild mode but ignore nonsensical files
set wildmenu
set wildmode=list:longest
set wildignore=*.swp,*.bak,*.pyc,*.class,*.o,*.obj,*~
set wildignore+=*DS_Store*
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=tmp/**
set wildignore+=*.png,*.jpg,*.gif
set wildignore+=*.so,*.swp,*.zip,*/.Trash/**,*.pdf,*.dmg,*/Library/**
set wildignore+=*/.nx/**,*.app
set splitright " always open new splits to the right of current
set splitbelow " always open new splits below current
" Whitespace
set autoindent " always indent
set copyindent " copy previous indent in insert mode
set smartindent
set wrap
set textwidth=79
set formatoptions=tcqrn1
" Tabs
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab " expand tabs to spaces
set noshiftround " round indents to multiple of shiftwidth
" Status bar
set laststatus=2
set showmode " show the mode in the status line
set showcmd " show the command in the status line
set showmatch " briefly jump to matching pairs/brackets
" Searching
nnoremap / /\v
vnoremap / /\v
set hlsearch " Highlight search results
set incsearch
set ignorecase
set smartcase " Ignore case if all lowercase
" Switch to last buffer
nnoremap <leader><tab> :b#<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment