" .vimrc - vim configuration " based on: https://stackoverflow.com/questions/1218390 " https://trofi.github.io/posts/277-from-mcedit-to-vim.html " https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim " https://github.com/CesarPiresSevero/vimconfig/blob/main/.vimrc " appearance set showmode " show current mode (insert/append/etc.) in status bar set showcmd " show typed command in status bar set number " show line numbers set ruler " show cursor position in status bar set background=dark " dark background (for tmux) " from: https://unix.stackexchange.com/a/363374 syntax on " enable syntax highlighting "set laststatus=2 " always show the status bar at the bottom "set showtabline=2 " show the tab bar even only one file is open "set cul " highlight cursor / current line (eqiv. 'set cursorline') "set cursorcolumn " highlight cursor / current line vertically " file type detection "filetype on "filetype plugin on "filetype indent on " window splitting set splitbelow " new horizontal splits are on the bottom set splitright " new vertical splits are on the right " indenting / wrapping set smartindent " smart auto indenting set expandtab " turn tabs into spaces set copyindent " copy indentation style of prior line set shiftwidth=4 " 4 spaces for auto indents set tabstop=4 " 4 spaces per tab "set nowrap " don't wrap lines "set textwidth=74 " set text width (for hardwrapping) " completion " https://stackoverflow.com/questions/9511253 set wildmenu set wildmode=longest:list,full set wildignore=*.o,*~,*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store,*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx " disable history and backups set viminfo= let g:netrw_dirhistmax=0 set nobackup set nowb set noswapfile " enhanced searching " https://www.twilio.com/blog/5-quality-of-life-vim-tricks-for-your-vimrc set hlsearch " highlight search terms set incsearch " highlight search terms as you type them set showmatch " highlight matching parentheses set ignorecase " case insensitive searching set smartcase " case sensitive if uppercase characters are provided nnoremap :noh " make Wq work lik wq " https://blog.sanctum.geek.nz/vim-koans/ command! Wq wq " highlight trailing white space in red " requires vim-runtime on Debian " https://stackoverflow.com/questions/356126 highlight ExtraWhitespace ctermbg=red guibg=red match ExtraWhitespace /\s\+$/ " highlight non-ascii characters in red " may require vim-runtime on Debian " https://stackoverflow.com/questions/16987362/ highlight nonascii guibg=Red ctermbg=1 term=standout au BufReadPost * syntax match nonascii "[^\u0000-\u007F]" " function to replace certain non-ascii characters with " their ascii equivalents function! ReplaceNonAscii() let save_cursor = getpos(".") let old_query = getreg('/') :%s/[“”]/"/ge :%s/[’’‘]/'/ge :%s/[ā]/a/ge :%s/[μμü]/u/ge :%s/η/n/ge :%s/ö/o/ge :%s/°/ \[deg\] /ge :%s/≳/\>\~/ge :%s/≲/\<\~/ge :%s/±/\+\/\-/ge :%s/[–−—]/\-/ge :%s/[      ]/ /ge :%s/→/\-\>/ge :%s/∞/\[infinity\]/ge :%s/²/\^2/ge call setpos('.', save_cursor) call setreg('/', old_query) endfunction nnoremap rr :call ReplaceNonAscii() " enable builtin spellchecking " https://vimtricks.com/p/vim-spell-check/ " https://www.linux.com/training-tutorials/using-spell-checking-vim/ " https://unix.stackexchange.com/questions/12889 " https://vi.stackexchange.com/questions/15578 " https://www.tumfatig.net/2024/spell-checking-in-vim/ let s:spellingState=0 function! ToggleSpelling() if s:spellingState set nospell else set spell spelllang=en_us endif let s:spellingState = !s:spellingState endfunction nnoremap :call ToggleSpelling() " remove trailing whitespace " https://vimtricks.com/p/vim-remove-trailing-whitespace/ " https://github.com/Omar12/dotfiles/blob/master/.vimrc function! StripWhitespace() let save_cursor = getpos(".") let old_query = getreg('/') :%s/\s\+$//e call setpos('.', save_cursor) call setreg('/', old_query) endfunction nnoremap ss :call StripWhitespace() " insert short date " https://vim.fandom.com/wiki/Insert_current_date_or_time nnoremap TT "=strftime('%m/%d/%Y')P nnoremap HH "=strftime('%H:%M')P