scriptencoding utf-8 execute pathogen#infect() " Set statements"{{{ set backspace=indent,eol,start set backup set backupdir=~/.vim/tmp//,. set directory=~/.vim/tmp//,. set encoding=utf-8 set history=50 set incsearch set ignorecase smartcase set listchars=space:·,tab:<>,nbsp:‗,eol:$,trail:§ set nocompatible set number set path=.,/usr/include,,,~,** " Fuzzy find-type settings from https://youtu.be/XA2WjJbmmoM set ruler set showcmd set splitbelow set splitright set wildmenu "set spell spelllang=en_us " EndSet "}}} " Conditionals"{{{ " In many terminal emulators the mouse works just fine, thus enable it. if has('mouse') set mouse=a endif " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif " Convenient command to see the difference between the current buffer and the " file it was loaded from, thus the changes you made. " Only define it when not defined already. if !exists(":DiffOrig") command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis \ | wincmd p | diffthis endif " EndConditionals "}}} " Autocommands"{{{ " Only do this part when compiled with support for autocommands. if has("autocmd") filetype plugin indent on augroup CleanUp autocmd! autocmd ColorScheme * highlight ExtraWhitespace ctermbg=darkmagenta guibg=red "match ExtraWhitespace /\s\+$/ autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@ 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif augroup END augroup VCenterCursor au! au BufEnter,WinEnter,WinNew,VimResized *,*.* \ let &scrolloff=winheight(win_getid())/2 augroup END augroup MapComment autocmd! autocmd FileType bash nnoremap cm I# autocmd FileType sh nnoremap cm I# autocmd FileType conf nnoremap cm I# autocmd FileType vim nnoremap cm 0i" augroup END augroup filetype_html autocmd! autocmd FileType html nnoremap f Vatzf augroup END augroup filetype_vim autocmd! autocmd FileType vim setlocal foldmethod=marker augroup END augroup filetype_help autocmd! autocmd FileType help setlocal nohls autocmd FileType help nnoremap /\v\\|.+\\| autocmd FileType help nnoremap autocmd FileType help nnoremap H autocmd FileType help nnoremap L augroup END "augroup AutoSaveFolds "This throws too many errors! " autocmd! " autocmd BufWinLeave * mkview " autocmd BufWinEnter * silent loadview "augroup END else set autoindent " always set autoindenting on endif " has("autocmd") " EndAutocommands "}}} " MyMappings"{{{ " Silly little mappings that make my life easier ;) let mapleader = "," let maplocalleader = "_" map! gUiw`]a| " Make word before cursor UPPERCASE inoremap =strftime("%F")| " Vimways.org: insert date inline inoremap u nnoremap g* g*zz nnoremap g# g#zz nnoremap H 0 nnoremap j jzz inoremap jk nnoremap k kzz nnoremap L $ inoremap `` ``''hi inoremap ` `'i inoremap < <>i inoremap ' ''i inoremap " ""i inoremap ( ()i inoremap [ []i inoremap { {}i inoremap * **i vnoremap `` ``>a'' vnoremap ` ``>a' vnoremap < ``>a>xp vnoremap ' ``>a' vnoremap " iW``>a"xp "vnoremap " ``>a" vnoremap ( ``>a) vnoremap [ ``>a] vnoremap { ``>a} vnoremap * ``>a* inoremap fu function __x__ {:}3kfxs nnoremap fu ifunction __x__ {:}3kfxs inoremap h "${HOME}" "nnoremap g :silent exe "grep! -R " . shellescape(expand("")) . " .":copen nnoremap kb :!grep "^\w*map\!*\s" $MYVIMRC sort -k2 -k1 > ~/.vim/mappings.txt:tabe ~/.vim/mappings.txt| " Show mappings in this file nnoremap n :cnext nnoremap p :cprevious inoremap se #----------------------------------- nnoremap se i#----------------------------------- inoremap v "${_}"hi inoremap x "$(_)"hi nnoremap ws :highlight TrailWS ctermbg=5 :match TrailWS /\v\s+$/ nnoremap ws :match nnoremap n nzz nnoremap N Nzz vnoremap . :norm. nnoremap Q :q! nnoremap :winc gF| " Open the file (on line number) in new tab nnoremap bb :tabe $HOME/.bashrc nnoremap co I 0f*Xciw+ md:r !date +\%F0D`dpJx| " Mark a gtd task complete nnoremap da :r !date +\%F" "\%ao| " Insert the date in YYYY-MM-DD Day format and insert two lines "nnoremap di me:r !date +\%FA 0D`ePJx| " Insert the date in YYYY-MM-DD format inline just before cursor position nnoremap di me:r !date -IsecondsA 0D`epJx| " Insert the date inline just after cursor position nnoremap do md:g/^\s*+/m$:set nohls`d| " Move completed tasks to the bottom of the list nnoremap fi :find ./.**/ nnoremap gf :winc gF| " Open the file (on line number) in new tab nnoremap gr :r | " Read contents of the file under the cursor into the current file nnoremap hh :w nnoremap hl :set nohls! nnoremap j L nnoremap k H nnoremap k H nnoremap lb ome:r !date -IminutesA 0D`ePJxI#log_begin | " Insert "#log_begin " and the date in ISO 8601 format on a new line below the cursor. nnoremap le ome:r !date -IminutesA 0D`ePJxI#log_end A (0 hrs 00 min)3F0| " Insert "#log_end ", the date in ISO 8601 format, and "(0 hrs 00 min)" on a new line below the cursor and go to the 0 before hrs. nnoremap li :set list!| " Toggle hidden characters nnoremap ns /\zs\\.*section\ze[^ ]zz| " Find next section in LaTeX nnoremap ok A%OK TMC nnoremap ps k?\zs\\.*section\ze[^ ]zz| " Find previous section in LaTeX nnoremap qq :q! nnoremap sa ggVG| " Select all nnoremap so :source $MYVIMRC "nnoremap L nnoremap L nnoremap sp :set nospell! nnoremap te :tabe nnoremap ti :r !date +\%R| " Insert the time in HH:MM format nnoremap vv :tabe $MYVIMRC nnoremap wc :winc | " Can't always use CTRL-W (esp. when working from Chromebook) nnoremap wh h nnoremap wj j nnoremap wk k nnoremap wl l nnoremap wq :wq nnoremap ws :%s/\s\+$//eg| " Find and kill trailing whitespace nnoremap ww w nnoremap th :tab help | nnoremap / /\v nnoremap Y y$ nnoremap * *zz nnoremap # #zz " EndMyMappings "}}} " Abbreviations"{{{ :ab echo printf "%b\n" :ab shebang #! /bin/bash " EndAbbreviations "}}} " Netrw"{{{ let g:netrw_banner = 0 let g:netrw_liststyle = 3 let g:netrw_browse_split = 3 let g:netrw_keepdir = 0 let g:netrw_fastbrowse = 0 " Possibly gets rid of [RO] netrw buffers: https://github.com/tpope/vim-vinegar/issues/13: * Monitor 2019-12-05 " EndNetrw "}}} " Functions"{{{ function! ViewHtmlText(url) if !empty(a:url) new setlocal buftype=nofile bufhidden=hide noswapfile execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0) 1d endif endfunction " Save and view text for current html file. nnoremap H :updatecall ViewHtmlText(expand('%:p')) " View text for visually selected url. vnoremap h y:call ViewHtmlText(@@) " View text for URL from clipboard. " On Linux, use @* for current selection or @+ for text in clipboard. nnoremap h :call ViewHtmlText(@+) " }}} " LaTeX"{{{ " These may be useful for working with LaTeX. "set wrap "set linebreak "set nolist "set textwidth=0 "set wrapmargin=0 ""filetype plugin on "set grepprg=grep\ -nH\ $* ""filetype indent on "let g:tex_flavor='latex' " EndLaTeX "}}} " Solarized colorscheme"{{{ set t_Co=256 let g:solarized_termcolors=256 call pathogen#infect() syntax on set background=light " dark | light " colorscheme solarized "filetype plugin on set cursorline set cursorcolumn set colorcolumn=80 call togglebg#map("") " EndSolarized "}}} " TODO Clean up this file! " " vim: set fdm=marker: