" --------------------------------------------------------------------------------------------------------------------- " ==> .vimrc set nocompatible " be iMproved, required set number " turn on line numbers set relativenumber " lines are numbered relative to current line set scrolloff=8 " number of lines to keep above and below the cursor set belloff=all " no sound/flash on errors set autoread " set to auto read when a file is changed from the outside "set cursorcolumn " highlight current column set cursorline " highlight current row set incsearch " make search act like search in modern browsers set showmatch " show matching brackets when text indicator is over them set term=xterm-256color " LOTS of colors set path+=** " Search Globally set wildmenu autocmd! bufwritepost .vimrc source ~/.vimrc " When vimrc is edited, reload it " Turn line numbers on/off for active/inactive buffers augroup BgHighlight autocmd! autocmd WinEnter * set number autocmd WinEnter * set relativenumber autocmd WinLeave * set nonumber autocmd WinLeave * set norelativenumber augroup end syntax enable filetype plugin on " --------------------------------------------------------------------------------------------------------------------- " ==> From Vim Zero: https://www.oliversherouse.com/2017/08/21/vim_zero.html " General let mapleader = ',' set hidden " Allow background buffers without saving set splitright " Split to right by default " Text Wrapping set textwidth=120 set colorcolumn= " disable color column set nowrap " Search and Substitute set gdefault " use global flag by default in s: commands set hlsearch " highlight searches set ignorecase " ignore case in searches set smartcase " don't ignore capitals in searches " Tabs set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab " --------------------------------------------------------------------------------------------------------------------- " ==> Plugins "" Installation with VimPlug if has("win32") call plug#begin('~/vimfiles/plugged') else call plug#begin('~/.vim/plugged') endif """ Basics " ...one step above 'nocompatible' mode: a universal set of defaults that (hopefully) everyone can agree on. Plug 'tpope/vim-sensible' " Syntax highlights for multiple languages Plug 'sheerun/vim-polyglot' " Syntax highlights for markdown Plug 'tpope/vim-markdown' " one stop shop for vim color schemes. Plug 'flazz/vim-colorschemes' " Command Line Fuzzy Finder - https://github.com/junegunn/fzf Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim' " fugitive.vim for git Plug 'tpope/vim-fugitive' call plug#end() " --------------------------------------------------------------------------------------------------------------------- " ==> Colors " "set termguicolors "colorscheme slate "colorscheme marklar "colorscheme automation colorscheme advantage highlight colorcolumn ctermbg=darkgray guibg=darkgray highlight VertSplit ctermbg=black guibg=black ctermfg=darkgray guifg=darkgray " In split windows - active buffer status bar is yellow, inactive is black hi statuslinenc ctermbg=gray ctermfg=black hi statusline ctermbg=black ctermfg=green " --------------------------------------------------------------------------------------------------------------------- " => Statusline " Ideas from http://got-ravings.blogspot.com/2008/08/vim-pr0n-making-statuslines-that-own.html set laststatus=2 " always show statusline set statusline= " clear on reload set statusline+=[\ b%n\ ] " buffer number set statusline+=\ %f " filename set statusline+=\ [%{strlen(&fenc)?&fenc:'none'}, " file encoding set statusline+=\ %{&ff}] " file format set statusline+=\ %y " filetype set statusline+=\ %H\ %m\ %r\ %W " flags set statusline+=%= " left/right separator set statusline+=l:%l/%L " cursor line/total lines set statusline+=\ c:%c " cursor column set statusline+=\ %P " percent through file " --------------------------------------------------------------------------------------------------------------------- " => Keymaps: Doing more things at once " turn off search hilight nnoremap :nohls " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps: Buffers " -H to move to previous buffer nnoremap :bp " -L to move to next buffer nnoremap :bn " comma-w to save buffer nnoremap w :w " comma-q to quit buffer nnoremap q :bd " bring up the copy buffer noremap x "+ " to refresh buffer nnoremap :checktime " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps: With ripgrep and FZF " p to open files map p :Files " search buffers nmap ; :Buffers " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps: Text bubbling (http://vimcasts.org/episodes/bubbling-text/) " Bubble single lines nmap ddkP nmap ddp " Bubble multiple lines vmap xkP`[V`] vmap xp`[V`] " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps: More sane movement keys nnoremap j gj nnoremap k gk " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps: Date and Time stamps imap =strftime("%Y-%m-%d %H:%M:%S") imap =strftime("%Y-%m-%d %a") imap =strftime("%H:%M") " --------------------------------------------------------------------------------------------------------------------- " ==> Spellcheck " Horrible colors! I hate spellchecker's red highlight, so I changed it " (http://stackoverflow.com/questions/6008921/how-do-i-change-the-highlight-style-in-vim-spellcheck) " Vim Colors: (http://alvinalexander.com/linux/vi-vim-editor-color-scheme-syntax) " Toggle spell check with F10 nnoremap :setlocal spell! spelllang=en_us set spell spelllang=en_us " Save custom dictionary in nextcloud so it's available on all machines set spellfile=/home/chawley/nextcloud-overlook/notes/system/en.utf-8.add hi clear SpellBad hi clear SpellCap hi clear SpellErrors hi clear SpellLocal hi clear SpellRare hi SpellBad cterm=underline ctermbg=black ctermfg=red hi SpellCap cterm=underline ctermbg=black ctermfg=red " --------------------------------------------------------------------------------------------------------------------- " ==> Spellcheck: only certain file types https://robots.thoughtbot.com/vim-spell-checking " turn off for files with no extension autocmd BufRead,BufNewFile * setlocal nospell " turn off for files with any extension autocmd BufRead,BufNewFile *.* setlocal nospell " turn on for markdown files autocmd BufRead,BufNewFile *.md setlocal spell " turn on for text files autocmd BufRead,BufNewFile *.txt setlocal spell " --------------------------------------------------------------------------------------------------------------------- " ==> Snippets " Pasting pre-made things " section banner nnoremap ,ban :-1read $HOME/.vim/templates/bannerjA " --------------------------------------------------------------------------------------------------------------------- " ==> Templates " Doing special things with certain filetypes " --------------------------------------------------------------------------------------------------------------------- " ==> Templates: shell scripts (.sh) autocmd BufNewFile *.sh so $HOME/.vim/templates/sh autocmd BufNewFile *.sh %s/FILE:.*/\='FILE: '.expand('%')/e autocmd BufNewFile *.sh exe "g/AUTHOR:.*/s//AUTHOR: C Hawley" autocmd BufNewFile *.sh exe "g/CREATED:.*/s//CREATED: " .strftime("%c") autocmd BufWritePre,filewritepre *.sh execute "normal ma" autocmd BufWritePre,filewritepre *.sh exe "g/REVISION:.*/s//REVISION: " .strftime("%c") autocmd bufWritePost,filewritepost *.sh execute "normal `a" " --------------------------------------------------------------------------------------------------------------------- " ==> Templates: python scripts (.py) autocmd BufNewFile *.py so $HOME/.vim/templates/py autocmd BufNewFile *.py %s/FILE:.*/\='FILE: '.expand('%')/e autocmd BufNewFile *.py exe "g/AUTHOR:.*/s//AUTHOR: C Hawley" autocmd BufNewFile *.py exe "g/CREATED:.*/s//CREATED: " .strftime("%c") autocmd BufWritePre,filewritepre *.py execute "normal ma" autocmd BufWritePre,filewritepre *.py exe "g/REVISION:.*/s//REVISION: " .strftime("%c") autocmd bufWritePost,filewritepost *.py execute "normal `a" " --------------------------------------------------------------------------------------------------------------------- " ==> Templates: markdown documents (.md, .mkd) autocmd BufNewFile *.md,*.mkd so $HOME/.vim/templates/md autocmd BufNewFile *.md,*.mkd exe "g/Created:.*/s//Created: " .strftime("%c") autocmd BufWritePre,filewritepre *.md,*.mkd execute "normal ma" autocmd BufWritePre,filewritepre *.md,*.mkd exe "g/Updated:.*/s//Updated: " .strftime("%c") autocmd bufWritePost,filewritepost *.md,*.mkd execute "normal `a" " --------------------------------------------------------------------------------------------------------------------- " ==> netrw - NERDtree like setup (https://shapeshed.com/vim-netrw/) let g:netrw_banner = 0 let g:netrw_liststyle = 3 let g:netrw_browse_split = 4 let g:netrw_altv = 1 let g:netrw_winsize = 25