set nocompatible syntax on "turn syntax highlighting on filetype plugin indent on "load plugin and indent files associated a detected filetype " macro to go to end of sentence and add a line break (for " one-line-per-sentence vimming...) let @s = ")i\\\" " leader let maplocalleader = "\\" let mapleader = "," " encryption method when using :X set cm=blowfish2 " Underline the current line, based on its length. noremap ul mmyypVr-`m " " Show the 'list' characters. noremap ls :set list! " Remove double- or single-quotes, or graves wrapped around a string. noremap rdq mmF"xf"x`m noremap rsq mmF'xf'x`m noremap rg mmF`xf`x`m " Jump up or down by 10 lines. noremap J 10j noremap K 10k " Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS). if (exists("*strftime")) noremap date "=strftime("%F")p9h noremap time "=strftime("%X")p7h endif " " Execute the current line with BASH. noremap rl :.w !bash " Run the current file with PERL, Python, BASH, or a Bourne Shell derivative. noremap rpl :!clear; perl % noremap rpy :!clear; python % noremap rb :!clear; bash % noremap rs :!clear; sh % set shell=/bin/sh set hi=500 set scrolloff=0 set novisualbell set relativenumber "show line numbers set wildmenu "enable a menu that shows tab completion options in the status bar set wildchar= set showmatch "highlights matching brackets on cursor hover set ruler "show cursor position in status bar set showcmd "shows the normal mode command before it gets executed set encoding=utf-8 set fileformats=unix,dos,mac set nohlsearch "highlights searches set incsearch "incremental search (searches character by character) set ignorecase "ignores the case of a search set smartcase "only ignores case if there are no capital letters in search (only works after ignorecase has been set) set tabstop=4 "the amount of spaces that vim will equate to a tab character set softtabstop=4 "like tabstop, but for editing operations (insert mode) set splitbelow " split horiz below set noswapfile set splitright " split new to the right when doing vertical set shiftwidth=4 "used for autoindent and << and >> operators in normal mode set autoindent "copies indent from current line to the next line set expandtab "tabs will expand to whitespace characters set esckeys "allows function keys to be recognized in Insert mode set ttimeoutlen=20 "timeout for a key code mapping set timeoutlen=1000 "time(ms) to wait for key mappings set hidden set t_Co=256 "set t_Co=0 - switches off all colours set path+=** set more set colorcolumn=0 set equalalways set showmode set nobackup set listchars=tab:»→,trail:␣ if executable('rg') set grepprg=rg\ --color=never\ --vimgrep endif " From Practical Vim p101 - Easy expansion of Active File Directory cnoremap %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' " i don't bother with folding, but it's here if i need it. if has('folding') set foldmethod=marker set foldmarker=#\ {{{,#\ }}} set viewoptions=folds,options,cursor,unix,slash endif " Check whether any buffers have been updated outside of vim nnoremap :checktime " Python - keybindings nnoremap Ts :setlocal makeprg=pytest\ -q\ % nnoremap Tf :setlocal makeprg=flake8\ % nnoremap Tb :setlocal makeprg=black\ % nnoremap Tm :setlocal makeprg=mypy\ --ignore-missing-imports\ % " then run the one set with this... nnoremap Tt :make! " clear search highlights nnoremap :noh:call clearmatches() " previews in netrw let g:netrw_preview = 1 " journal stuff autocmd BufNewFile,BufReadPost *.md map jj :r! date +" - \%H:\%M: "kJA$ autocmd BufNewFile,BufReadPost *.md map jd :r! date +"(\%Y-\%m-\%dT\%H:\%M)"i " ghetto note system " Go to index of notes nnoremap ni :e $NOTES_DIR/index.md:cd $NOTES_DIR " Depends on grepprg being set to rg command! -nargs=1 Ngrep grep "" -g "*.md" $NOTES_DIR nnoremap nn :Ngrep " open quicklist vertical command! Vlist botright vertical copen | vertical resize 50 nnoremap v :Vlist " Search with ripgrep command! -bang -nargs=* Rg \ call fzf#vim#grep( \ 'rg --column --line-number --no-heading --color=always --ignore-case '.shellescape(), 1, \ 0 ? fzf#vim#with_preview('up:60%') \ : fzf#vim#with_preview('right:50%:hidden', '?'), \ 0) nnoremap a :Rg "" Quick Editing vimrc nnoremap ev sjL:e $MYVIMRC set background=dark colorscheme hipster " manual highlights " highlight Visual ctermfg=black ctermbg=LightMagenta " highlight SignColumn ctermbg=black ctermfg=white " highlight Comment ctermfg=DarkGray " highlight DiffAdd term=bold ctermfg=yellow ctermbg=black " highlight DiffDelete term=bold ctermfg=red ctermbg=black " highlight DiffChange term=bold ctermfg=black ctermbg=DarkGreen augroup general autocmd! "keep equal proportions when windows resized autocmd VimResized * wincmd = "save cursor position in a file autocmd BufReadPost * if line("'\"") > 1 && line("'\"") \ <= line("$") | exe "normal! g'\"" | endif augroup END augroup languages autocmd! autocmd BufNewFile,BufRead *.bash set syntax=sh autocmd FileType python xnoremap r :'<,'>:w !python3 autocmd FileType go set noexpandtab autocmd FileType html :syntax sync fromstart autocmd FileType html,javascript,css,json,yaml,sh \ setlocal ts=2 sts=2 sw=2 expandtab augroup END