Skip to content

Instantly share code, notes, and snippets.

@jweiss
Created April 18, 2026 20:45
Show Gist options
  • Select an option

  • Save jweiss/7c2c42da444d735dbf94fb6871ea911f to your computer and use it in GitHub Desktop.

Select an option

Save jweiss/7c2c42da444d735dbf94fb6871ea911f to your computer and use it in GitHub Desktop.
vimrc
" =============================================================================
" ~/.vimrc — pragmatic config for Unix / Ruby / Python / Julia / Node / Make
" No plugins required for base functionality. Optional plug block at the end.
" =============================================================================
set nocompatible
set encoding=utf-8
scriptencoding utf-8
syntax on
filetype plugin indent on
" --- UI ----------------------------------------------------------------------
"set number relativenumber " hybrid line numbers
set number " normal line numbers
set cursorline
set showmatch
set ruler laststatus=2 showcmd
set wildmenu
set wildmode=longest:full,full
set wildignore+=*.o,*.obj,*.pyc,*.class,*.so,*.swp,node_modules/**,.git/**
set signcolumn=yes
set scrolloff=8 sidescrolloff=8
set splitbelow splitright
set lazyredraw ttyfast title
if has('termguicolors') && ($COLORTERM =~# 'truecolor\|24bit')
set termguicolors
endif
set background=dark
silent! colorscheme habamax " ships with Vim 9; silent fallback otherwise
" --- Editing -----------------------------------------------------------------
set backspace=indent,eol,start
set hidden " allow unsaved buffers in background
set mouse=a
set clipboard^=unnamed,unnamedplus " use system clipboard (needs +clipboard)
set autoread
set autoindent smartindent
set expandtab
set tabstop=2 softtabstop=2 shiftwidth=2
set shiftround smarttab
set nowrap linebreak
set nojoinspaces
" --- Search ------------------------------------------------------------------
set incsearch hlsearch
set ignorecase smartcase
if executable('rg')
set grepprg=rg\ --vimgrep\ --smart-case\ --hidden
set grepformat=%f:%l:%c:%m
endif
" --- History / undo / swap (keep the project tree clean) ---------------------
set history=1000 undolevels=1000
set undofile
set undodir=~/.vim/undo//
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
silent! call mkdir(expand('~/.vim/undo'), 'p')
silent! call mkdir(expand('~/.vim/backup'), 'p')
silent! call mkdir(expand('~/.vim/swap'), 'p')
" --- Responsiveness ----------------------------------------------------------
set updatetime=300
set timeoutlen=500 ttimeoutlen=10
" --- Leader + core mappings --------------------------------------------------
let mapleader = ' '
let maplocalleader = '\'
nnoremap <leader>w :write<CR>
nnoremap <leader>q :quit<CR>
nnoremap <silent> <leader><space> :nohlsearch<CR>
" Window nav
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Buffer nav
nnoremap <leader>bn :bnext<CR>
nnoremap <leader>bp :bprevious<CR>
nnoremap <leader>bd :bdelete<CR>
" Keep visual selection after shifting
vnoremap < <gv
vnoremap > >gv
" Move visual selection
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Edit / reload vimrc
nnoremap <leader>ve :edit $MYVIMRC<CR>
nnoremap <leader>vs :source $MYVIMRC<CR>
" --- Language-specific -------------------------------------------------------
augroup ft_indents
autocmd!
autocmd FileType ruby,eruby,yaml,javascript,typescript,json,html,css,scss
\ setlocal tabstop=2 softtabstop=2 shiftwidth=2
autocmd FileType python setlocal tabstop=4 softtabstop=4 shiftwidth=4
\ textwidth=99 colorcolumn=100
autocmd FileType julia setlocal tabstop=4 softtabstop=4 shiftwidth=4
autocmd FileType go setlocal noexpandtab tabstop=4 shiftwidth=4
autocmd FileType make setlocal noexpandtab " Make needs real tabs
autocmd FileType markdown setlocal wrap linebreak spell spelllang=en_us
autocmd FileType gitcommit setlocal spell spelllang=en_us textwidth=72
augroup END
" Filetype plugins keep re-adding cro; override per buffer
augroup no_autocomment
autocmd!
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
augroup END
" Strip trailing whitespace on save (except where it matters)
augroup strip_trailing
autocmd!
autocmd BufWritePre * if index(['markdown','diff','mail'], &ft) < 0
\ | let s:v = winsaveview() | %s/\s\+$//e | call winrestview(s:v) | endif
augroup END
" Remember cursor position
augroup remember_cursor
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$")
\ | execute "normal! g`\"" | endif
augroup END
" --- Netrw (built-in file explorer, no plugin needed) ------------------------
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_winsize = 25
nnoremap <leader>e :Lexplore<CR>
" =============================================================================
" OPTIONAL: vim-plug — uncomment, install vim-plug, then :PlugInstall
" https://github.com/junegunn/vim-plug
" =============================================================================
"
" call plug#begin(has('nvim') ? stdpath('data').'/plugged' : '~/.vim/plugged')
" Plug 'tpope/vim-sensible'
" Plug 'tpope/vim-commentary' " gcc / gc in visual
" Plug 'tpope/vim-surround' " cs'\" etc.
" Plug 'tpope/vim-fugitive' " :Git ...
" Plug 'airblade/vim-gitgutter'
" Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" Plug 'junegunn/fzf.vim' " :Files :Rg :Buffers
" Plug 'itchyny/lightline.vim'
" Plug 'morhetz/gruvbox'
"
" " Language support
" Plug 'vim-ruby/vim-ruby'
" Plug 'Vimjas/vim-python-pep8-indent'
" Plug 'JuliaEditorSupport/julia-vim'
" Plug 'pangloss/vim-javascript'
" Plug 'HerringtonDarkholme/yats.vim' " TypeScript
" call plug#end()
"
" nnoremap <leader>ff :Files<CR>
" nnoremap <leader>fg :Rg<CR>
" nnoremap <leader>fb :Buffers<CR>
" silent! colorscheme gruvbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment