Skip to content

Instantly share code, notes, and snippets.

@kaem-e
Last active January 11, 2026 18:48
Show Gist options
  • Select an option

  • Save kaem-e/3539c743d4c2e3c9446f47aa29243927 to your computer and use it in GitHub Desktop.

Select an option

Save kaem-e/3539c743d4c2e3c9446f47aa29243927 to your computer and use it in GitHub Desktop.
Minimal .vimrc that can be fetched via curl/wget or scp on a remote machine
" Minimal .vimrc that can be fetched via curl/wget or scp on a remote machine
" • curl -fLOsS https://gist.githubusercontent.com/kaem-e/3539c743d4c2e3c9446f47aa29243927/raw/.vimrc
" • wget -c https://gist.githubusercontent.com/kaem-e/3539c743d4c2e3c9446f47aa29243927/raw/.vimrc -O ~/.vimrc
" • (for ssh remotes, via scp): scp ./.vimrc madoka@_HOST_:~/.vimrc
" ---- Options -----
set nocompatible
set t_Co=16 " limit to ansi-16
set notermguicolors
set noswapfile
set nobackup
set lazyredraw
set nowritebackup
set belloff=all
set splitbelow
set splitright
set autoindent
set smartindent
set smarttab
set tabstop=3
set shiftwidth=0
set softtabstop=0
set smoothscroll
set confirm
syntax on
filetype plugin indent on
set ignorecase
set smartcase
set incsearch
augroup vimrc_incsearch_highlight
autocmd!
autocmd CmdlineEnter [\/\?] :set hlsearch
augroup END
set showmatch
set clipboard+=autoselectplus
set scrolloff=10
set mouse= " Disable Mouse Input
set shortmess+=atWIFSFCTO
set encoding=utf-8
set fileencoding=utf-8
autocmd FileType vim setlocal keywordprg=:help " open vim help for viml files
autocmd FileType systemd setlocal keywordprg=:!systemctl help
" ---- Visuals/Appearance & Indent Lines ----
set number
set laststatus=0
set noshowmode
set noruler
set fillchars=eob:\ ,vert:│,fold:─,
set cursorline
set cursorlineopt=number
set background=light
color pablo
" color shine
" color sorbet
" Cursor Customization
let &t_SI = "\<Esc>[6 q" " Vertical bar
let &t_SR = "\<Esc>[1 q" " Block
let &t_EI = "\<Esc>[4 q" " Underline
" Highlights
highlight Normal ctermbg=NONE
highlight Visual ctermbg=0 ctermfg=NONE
highlight NonText ctermbg=NONE
highlight VertSplit ctermbg=NONE
highlight StatusLineNC cterm=underline ctermbg=NONE
highlight StatusLine ctermbg=NONE cterm=NONE
highlight StatusLineNC ctermbg=NONE cterm=NONE
highlight Search ctermbg=NONE ctermfg=NONE cterm=underline
highlight CurSearch ctermbg=NONE ctermfg=1 cterm=bold,underline term=NONE
highlight IncSearch ctermbg=NONE ctermfg=1 cterm=bold,underline term=NONE
highlight CursorLineNr ctermbg=8, ctermfg=7 cterm=BOLD
highlight PmenuShadow ctermbg=1 ctermfg=NONE
highlight MatchParen ctermbg=NONE ctermfg=NONE cterm=underline,bold
" ----- Keybindings/(auto)groups -----
let mapleader = " "
nnoremap <leader>l $
nnoremap <leader>h ^
vnoremap <leader>l $h
vnoremap <leader>h ^
nnoremap U <C-r>
vnoremap <S-j> :m '>+1<CR>gv=gv
vnoremap <S-k> :m '<-2<CR>gv=gv
nnoremap ~ ~h
vnoremap < <gv
vnoremap > >gv
vnoremap <C-a> <C-a>gv
vnoremap <C-x> <C-x>gv
vnoremap p "_dp
vnoremap P "_dP
nnoremap <silent> <esc> :nohlsearch<CR><esc>
cmap w!! w !sudo tee > /dev/null % " w!! to force write via sudo
cmap s/ s/\v
" Auto Reload Vimrc
nnoremap <leader>rv :source $MYVIMRC<CR>:echo "Reloaded " . $MYVIMRC<CR>
nnoremap <leader>rV :edit $MYVIMRC<CR>
augroup reload_vimrc
autocmd!
autocmd BufWritePost $MYVIMRC silent source $MYVIMRC | redraw!
augroup END
" Minimal Commentary (line or visual)
nnoremap <silent> gcc :call ToggleComment()<CR>
xnoremap <silent> gc :call ToggleComment()<CR>
function! ToggleComment() range
let c = '#'
if &filetype ==# 'vim' | let c = '"' |
elseif index(['lua','sql'], &filetype) >= 0 | let c = '--' |
elseif index(['c','cpp','rust'], &filetype) >= 0 | let c = '//' |
endif
for lnum in range(a:firstline,a:lastline)
let line = getline(lnum)
if line =~ '^\s*'.c
call setline(lnum, substitute(line,'^\(\s*\)'.c.'\s\?','\1',''))
else | call setline(lnum, substitute(line,'^\s*','\0'.c.' ','')) |
endif
endfor
endfunction
" Minimal Surround (Visual Mode)
vnoremap S :<C-u>call VisualSurround()<CR>
function! VisualSurround()
let c = nr2char(getchar())
let [l, r] = [c, c]
if c == '(' | let [l, r] = ['(', ')'] | endif
if c == '[' | let [l, r] = ['[', ']'] | endif
if c == '{' | let [l, r] = ['{', '}'] | endif
if c == '<' | let [l, r] = ['<', '>'] | endif
exe "normal! `>a" . r . "\<Esc>`<i" . l . "\<Esc>"
endfunction
" Minimal Sleuth-like auto-indent detector
function! DetectIndent()
let sp = search('^ \+', 'nW') | let tb = search('^\t', 'nW')
if tb>0 && (sp==0 || tb<sp) | set noexpandtab tabstop=3 shiftwidth=0 |
elseif sp>0
let sw = strlen(matchstr(getline(sp), '^ \+'))
if sw>0 | set expandtab | let &shiftwidth=sw | let &tabstop=sw | endif
else | set expandtab shiftwidth=3 tabstop=3 |
endif
endfunction
autocmd BufReadPost * silent! call DetectIndent()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment