Skip to content

Instantly share code, notes, and snippets.

@brettowe
Created May 12, 2026 20:38
Show Gist options
  • Select an option

  • Save brettowe/1b87776eb80b6ec56ca1591fa501c383 to your computer and use it in GitHub Desktop.

Select an option

Save brettowe/1b87776eb80b6ec56ca1591fa501c383 to your computer and use it in GitHub Desktop.
vimrc
":set verbose=9
" not vi Compatable
set nocompatible
" encoding to utf-8
set tenc=utf-8
set enc=utf-8
" quiet erroring
set noerrorbells
set novisualbell
" --- Color/look Options
" makes background black and foreground white
:highlight Normal guifg=White guibg=Black
" make fg blue on folded lines
:highlight Folded ctermfg=Blue guifg=Blue
if version >= 700
" make visual readable
:highlight Visual ctermfg=Black guifg=Black ctermbg=White guibg=White
endif
" don't refresh screen when macros are running
set lazyredraw
" turns on syntax highlighting (colors!)
if has("syntax")
:syntax on
endif
" set history length also affects how viminfo works
set history=50
" set viminfo file options
set viminfo='30,<50,"500,s200,h,f1
" dont match brackets
":NoMatchParen
" change color scheme
":color asu1dark
" change tite string in vim6 to vim 5x style
set title titlestring=VIM\ -\ %F\ %h
" puts status line there always in a line by itself
set laststatus=2
" custom status line
" filename =(right justify) file format
" [line #/total lines,percent in file, position in line]
set statusline=%F%m%r%h%w\ %=%{&ff}\ [%03l/%03L,%02P,%03v]
" turns on ruler
set ruler
" cool tab completion menu
set wildmenu
" line numbers
set number
" line number width
set numberwidth=3
function! Font_exists(font)
exec system("fc-list -q '" . a:font ."'")
return v:shell_error == 0
endfunction
" set the gui
if has("gui")
set linespace=2
if has("win32")
colorscheme darkblue
set guifont=Fira_Code:h12:cANSI:qDRAFT
if has("directx")
" for proper rendering encoding=utf-8 is required
set renderoptions=type:directx:renmode:1
endif
else
if Font_exists('Intel One Mono')
set guifont=Intel\ One\ Mono\ 12
elseif Font_exists('Fira Mono')
set guifont=Fira\ Mono\ 12
elseif Font_exists('Fira Code')
set guifont=Fira\ Code\ 12
elseif Font_exists('PrimaSans')
set guifont=PrimaSansMono\ BT\ 12
elseif Font_exists('Console')
set guifont=Console\ 10
elseif Font_exists('DejaVu')
set guifont=DejaVu\ Sans\ Mono\ 10
endif
endif
else
" console colors?
"colorscheme elflord
endif
" --- Search Options
" dont highlight words that match a search
set nohlsearch
" ignore case for searching
set ignorecase
" if there is mix of LoWEr and upper case in search
" it will do case sensitive search instead
set smartcase
" start searching as you type in the pattern
set incsearch
" --- Folding Options
" set folding method to marker
set fdm=manual
" :let perl_fold=1
" set modelines so global vimrc files dont fuck us over
set modelines=3
" --- Misc Options
" dont force files to be written to disk
set nofs
" bind windows scrolling
" scrollbind
" set printer device
set pdev=pdf
" set printer options
set printoptions=paper:letter,syntax:n
" turns on autoindenting
set autoindent
" turns on smart indent
set smartindent
" makes backspace work right
" (in insert mode backspace does backspace)
set backspace=2
" turn off wrap in window
"set nowrap
" if for some reason u want to make tab less than 8 spaces
":set tabstop=4
" hide mouse when typing
set mousehide
" formatting options (should insert * when starting a /* and goto next line
set formatoptions=tcrq
if has("spell") && hostname() == "somehostname"
" set spelling language so spell check can work
setlocal spell spelllang=en_us
" disable spell checking on load tho
set nospell
endif
" general useful automappings
"
" return to last cursor position
:autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_postion_alone") |
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
" Show trailing whitespace and spaces before tabs
:hi link localWhitespaceError Error
:autocmd Syntax * :syntax match localWhitespaceError /\(\zs\%#\|\s\)\+$/ display
:autocmd Syntax * :syntax match localWhitespaceError / \+\ze\t/ display
" makes it sync syntax from start of file
" makes syntax always look right
:autocmd BufEnter *.php :syntax sync fromstart
:autocmd BufEnter *.html :syntax sync fromstart
:autocmd BufEnter *.js :syntax sync fromstart
" python tunning
:autocmd BufNewFile,BufRead *.py,*.pyw let python_highlight_all=1
:autocmd BufNewFile,BufRead *.py,*.pyw match localWhitespaceError /^\t\+/
:autocmd BufNewFile,BufRead *.py,*.pyw match localWhitespaceError /\s\+$/
:autocmd BufNewFile,BufRead *.py,*.pyw set tabstop=4
:autocmd BufNewFile,BufRead *.py,*.pyw set softtabstop=4
:autocmd BufNewFile,BufRead *.py,*.pyw set shiftwidth=4
:autocmd BufNewFile,BufRead *.py,*.pyw set expandtab
:autocmd BufNewFile,BufRead *.py,*.pyw set fileformat=unix
:autocmd BufNewFile,BufRead *.py,*.pyw set listchars=tab:-->
:autocmd BufNewFile,BufRead *.py,*.pyw set list
:autocmd BufNewFile,BufRead *.js,*.html set tabstop=4
:autocmd BufNewFile,BufRead *.js,*.html set softtabstop=4
:autocmd BufNewFile,BufRead *.js,*.html set shiftwidth=4
:autocmd BufNewFile,BufRead *.js,*.html set expandtab
" leaving msg
:autocmd VimLeave * echo "Thanks for flying VIM."
" general mappings
" this will add closing brackets when { is hit
:autocmd BufNewFIle,BufRead *.go,*.c,*.h,*.cpp :inoremap { {<CR>}<Esc>O
" this will spell check the whole file with ispell
" from <fridge> in #vim
":map<Leader>s :w<CR>:!ispell -x %<CR>:e<CR><CR>
" this will take whats selected and put /* */ around it
" this is from <fridge> in #vim
:vmap C <C-G><C-BS>i/* */<Left><Left><Left><C-[>p
" <Leader> mappings
" default leader should be \ but had to set it to work
:let mapleader = "\\"
" map <Leader>tf to insert the date
" example: Sat, 14 Jul 2007 14:27:46 -0700
if exists("*strftime")
:imap <Leader>tf <esc>:execute "normal a" . strftime("%a, %d %b %Y %R:%S %z")<cr><right>
endif
" :FoldPatch will fold a diff or patch for easier browsing
:autocmd BufEnter *.patch :call FoldPatch()
:autocmd BufEnter *.diff :call FoldPatch()
:command! -nargs=0 FoldPatch call FoldPatch()
:command! -nargs=0 FoldSvnPatch call FoldSvnPatch()
function FoldPatchSupport(start_str)
let lold = line(".")
let ln = search(a:start_str, 'W')
while ln > lold
" diff and execute folding
let diff = ln - lold - 1
let str = "zf".diff."j"
execute ':'. lold
execute "normal ". str
" search next
let lold = ln
execute ':' . lold
let ln = search(a:start_str, 'W')
endwhile
normal zfG
normal 1G
endfunction
function FoldSvnPatch()
:call FoldPatchSupport("^Index")
endfunction
function FoldPatch()
:call FoldPatchSupport("^diff")
endfunction
" :Sort takes a range of lines and sorts them.
command! -nargs=0 -range Sort <line1>,<line2>call Sort("Strcmp")
" To Sort a range of lines, pass the range to Sort() along with the name of a
" function that will compare two lines.
function! Sort(cmp) range
call SortR(a:firstline, a:lastline, a:cmp)
endfunction
" Sort lines. SortR() is called recursively.
function! SortR(start, end, cmp)
if (a:start >= a:end)
return
endif
let partition = a:start - 1
let middle = partition
let partStr = getline((a:start + a:end) / 2)
let i = a:start
while (i <= a:end)
let str = getline(i)
exec "let result = " . a:cmp . "(str, partStr)"
if (result <= 0)
" Need to put it before the partition. Swap lines i and partition.
let partition = partition + 1
if (result == 0)
let middle = partition
endif
if (i != partition)
let str2 = getline(partition)
call setline(i, str2)
call setline(partition, str)
endif
endif
let i = i + 1
endwhile
" Now we have a pointer to the "middle" element, as far as partitioning
" goes, which could be anywhere before the partition. Make sure it is at
" the end of the partition.
if (middle != partition)
let str = getline(middle)
let str2 = getline(partition)
call setline(middle, str2)
call setline(partition, str)
endif
call SortR(a:start, partition - 1, a:cmp)
call SortR(partition + 1, a:end, a:cmp)
endfunction
" Function for use with Sort(), to compare two strings.
function! Strcmp(str1, str2)
if (a:str1 < a:str2)
return -1
elseif (a:str1 > a:str2)
return 1
else
return 0
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment