From 5613555960380003a2d26b1ea6c469c35e5c0b65 Mon Sep 17 00:00:00 2001 From: phansible Date: Tue, 13 Feb 2024 11:29:43 -0500 Subject: [PATCH] Sweeping changes to vim environment Details in README.md --- .vim/templates/md | 3 +- .vim/templates/sh | 1 - .vim/vim-keys-help.md | 55 +++++++++++ .vim/vim-keys.md | 42 -------- .vimrc | 223 +++++++++++++++++++----------------------- README.md | 23 +++-- 6 files changed, 170 insertions(+), 177 deletions(-) create mode 100644 .vim/vim-keys-help.md delete mode 100644 .vim/vim-keys.md diff --git a/.vim/templates/md b/.vim/templates/md index 3861ce8..7d1dbdc 100644 --- a/.vim/templates/md +++ b/.vim/templates/md @@ -1,6 +1,7 @@ -:insert # title +Updated: + --- ## Summary diff --git a/.vim/templates/sh b/.vim/templates/sh index 9acac80..2961759 100644 --- a/.vim/templates/sh +++ b/.vim/templates/sh @@ -1,4 +1,3 @@ -:insert #!/usr/bin/env bash #=============================================================================== # diff --git a/.vim/vim-keys-help.md b/.vim/vim-keys-help.md new file mode 100644 index 0000000..6c22bb7 --- /dev/null +++ b/.vim/vim-keys-help.md @@ -0,0 +1,55 @@ +# vim-keys + +A cheat sheet for my vim customizations + +--- + +## Spelling + +`-p` - auto-complete spelling suggestions +`` - toggle spellcheck + +## Highlights + +`` - turn off search highlight +`C` - toggle row/column cursor + +## Buffers + +`H` - to move to previous BUFFER +`L` - to move to next BUFFER +`J` - to move to lower PANE +`K` - to move to upper PANE + +`s` - to save buffer +`c` - to close buffer +`a` - to abandon unsaved buffer + +`x` - bring up the copy buffer +`` - refresh buffer + +`r` - open registers + +## FZF + +`f` - open FZF files +`b` - open FZF buffers + +## Text bubbling (http://vimcasts.org/episodes/bubbling-text/) + +After text selection (``) +`k` - bubble up +`j` - bubble down + +## Date and Time stamps + +`` - insert %Y-%m-%d %H:%M:%S +`` - insert %Y-%m-%d %a +`` - insert %H:%M + +## Snippets +pre-made files inserted from `.vim/templates` + +`,sh` - insert shell header +`,md` - insert markdown header +`,ban` - insert ASCII banner diff --git a/.vim/vim-keys.md b/.vim/vim-keys.md deleted file mode 100644 index 72b2c72..0000000 --- a/.vim/vim-keys.md +++ /dev/null @@ -1,42 +0,0 @@ -# /home/phansible/vim-keys - -## Highlights - -`` - turn off spellcheck highlights -`` - turn off search highlight -`c` - toggle row/column cursor - -## Buffers & Panes - -`-H` - to move to previous BUFFER -`-L` - to move to next BUFFER -`-J` - to move to lower PANE -`-K` - to move to upper PANE - -`-s` - to save buffer -`-c` - to close buffer - -`-x` - bring up the copy buffer -`` - refresh buffer - -## FZF - -`-f` - open files -`;` - open buffers - -## Text bubbling (http://vimcasts.org/episodes/bubbling-text/) - -After text selection (``) -`-k` - bubble up -`-j` - bubble down - -## Date and Time stamps - -`` - insert %Y-%m-%d %H:%M:%S -`` - insert %Y-%m-%d %a -`` - insert %H:%M - ---- - -`-p` - auto-complete spelling suggestions - diff --git a/.vimrc b/.vimrc index 15fb4da..4f7e8fd 100644 --- a/.vimrc +++ b/.vimrc @@ -1,20 +1,20 @@ " --------------------------------------------------------------------------------------------------------------------- " ==> .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 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 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 term=xterm-256color " LOTS of colors +set path+=** " Search Globally set wildmenu autocmd! bufwritepost .vimrc source ~/.vimrc " When vimrc is edited, reload it @@ -31,6 +31,9 @@ augroup end syntax enable filetype plugin on +" Native Markdown syntax highlighting for specified languages +let g:markdown_fenced_languages = ['html', 'python', 'sh', 'vim'] + " --------------------------------------------------------------------------------------------------------------------- " ==> From Vim Zero: https://www.oliversherouse.com/2017/08/21/vim_zero.html @@ -41,9 +44,9 @@ set splitright " Split to right by default set formatoptions-=ro " Turn off autoinsert of comment char on newline " Text Wrapping -set textwidth=120 -set colorcolumn= " disable color column -set nowrap +set textwidth=120 " Set textwidth +set colorcolumn= " disable colorzing column +set nowrap " turn off word wrapping at " Search and Substitute set gdefault " use global flag by default in s: commands @@ -58,50 +61,45 @@ set shiftwidth=4 set expandtab " --------------------------------------------------------------------------------------------------------------------- -" ==> Plugins +" ==> Plugins with VimPlug +" A minimalist Vim plugin manager +" https://github.com/junegunn/vim-plug -"" 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. +" Think of sensible.vim as one step above 'nocompatible' mode: a universal set of defaults that (hopefully) everyone can agree on +" https://github.com/tpope/vim-sensible Plug 'tpope/vim-sensible' -" Syntax highlights for markdown -Plug 'tpope/vim-markdown' - -" one stop shop for vim color schemes. +" One stop shop for vim colorschemes +" https://github.com/flazz/vim-colorschemes Plug 'flazz/vim-colorschemes' -" Command Line Fuzzy Finder - https://github.com/junegunn/fzf +" 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 +" Fugitive is the premier Vim plugin for Git. Or maybe it's the premier Git plugin for Vim? Either way, +" it's so awesome, it should be illegal. That's why it's called Fugitive +" https://github.com/tpope/vim-fugitivefugitive.vim for git Plug 'tpope/vim-fugitive' -" vim.vinegar -Plug 'tpope/vim-vinegar' - -" Linter +" ALE displays warnings and errors in files being edited before being saved back to the filesystem +" https://github.com/dense-analysis/ale Plug 'dense-analysis/ale' -" Syntax highlights for multiple languages -"Plug 'sheerun/vim-polyglot' - call plug#end() -" --------------------------------------------------------------------------------------------------------------------- -" ==> Plugin options -" " --------------------------------------------------------------------------------------------------------------------- " ==> Colors -" -"set termguicolors +" Term GUI Colors +" Testing different colorschemes +" Only the last uncommented colorscheme will be used "colorscheme slate "colorscheme marklar "colorscheme automation @@ -112,7 +110,6 @@ colorscheme advantage highlight cursorcolumn cterm=NONE ctermbg=black ctermfg=white guibg=darkred guifg=white "highlight visual cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white - " In split windows - active buffer status bar is yellow, inactive is black "hi statuslinenc ctermbg=gray ctermfg=black "hi statusline ctermbg=yellow ctermfg=green @@ -135,56 +132,71 @@ set statusline+=\ c:%c " cursor column set statusline+=\ %P " percent through file " --------------------------------------------------------------------------------------------------------------------- -" => Keymaps: Doing more things at once +" => Keymaps: Highlights -" turn off search highlight -nnoremap :nohls -" toggle row/column cursor -nnoremap c :set cursorline! cursorcolumn! +" to turn off search highlight +nnoremap :nohls + +" C to toggle row/column highlight +nnoremap C :set cursorline! cursorcolumn! " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps: Buffers & Panes -" -H to move to previous BUFFER +" H to move to previous BUFFER nnoremap :bp -" -L to move to next BUFFER + +" L to move to next BUFFER nnoremap :bn -" -J to move to lower PANE + +" J to move to lower PANE nnoremap -" -K to move to upper PANE + +" K to move to upper PANE nnoremap -" -s to save buffer +" b to open FZF buffers +map b :Buffers + +" s to save buffer nnoremap s :w -" -c to close buffer + +" c to close buffer nnoremap c :bd -" bring up the copy buffer +" a to abandon buffer +nnoremap a :bd! + +" x to bring up the copy buffer noremap x "+ -" to refresh buffer + +" to refresh buffer nnoremap :checktime " --------------------------------------------------------------------------------------------------------------------- -" ==> Keymaps: With ripgrep and FZF +" ==> Keymaps -" f to open files +" f to open FZF files map f :Files -" search buffers -nmap ; :Buffers + +" r to open registers +map r :registers " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps: Text bubbling (http://vimcasts.org/episodes/bubbling-text/) -" Bubble single lines +" Bubble single lines nmap ddkP nmap ddp -" Bubble multiple lines + +" Bubble multiple lines vmap xkP`[V`] vmap xp`[V`] " --------------------------------------------------------------------------------------------------------------------- -" ==> Keymaps: More sane movement keys +" ==> Keymaps: Movement keys +" Navigate according to displayed lines, not physical lines nnoremap j gj nnoremap k gk @@ -195,32 +207,33 @@ imap =strftime("%Y-%m-%d %H:%M:%S") imap =strftime("%Y-%m-%d %a") imap =strftime("%H:%M") - " --------------------------------------------------------------------------------------------------------------------- " --------------------------------------------------------------------------------------------------------------------- -" ==> 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 - " ==> Spellcheck -set spell spelllang=en_us - -" Toggle spell check with F10 +" Toggle spell check highlights with nnoremap :setlocal spell! spelllang=en_us -" auto-complete spelling suggestions with +" auto-complete spelling suggestions with set complete+=kspell -" Horrible colors! I hate spellchecker's red highlight, so I changed it +" ==> 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 + +" ==> Spellcheck Colors +" I hate spellcheck's default colors " (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) hi clear SpellBad @@ -232,63 +245,26 @@ hi SpellBad cterm=underline ctermbg=black ctermfg=red hi SpellCap cterm=underline ctermbg=black ctermfg=red " --------------------------------------------------------------------------------------------------------------------- - " ==> Snippets " Pasting pre-made things -" section banner +" section banner nnoremap ,ban :-1read $HOME/.vim/templates/bannerjA -" section begin/end +" section begin/end nnoremap ,begend :-1read $HOME/.vim/templates/begendjA -" --------------------------------------------------------------------------------------------------------------------- -" ==> Templates -" Doing special things with certain filetypes +" section shell script header +nnoremap ,shead :-1read $HOME/.vim/templates/shjA + +" section markdown file header +nnoremap ,md :-1read $HOME/.vim/templates/mdjA " --------------------------------------------------------------------------------------------------------------------- -" ==> Templates: shell scripts (.sh) +" ==> NetrwTreeListing readonly fix (https://vi.stackexchange.com/a/13012) +" Per default, netrw leaves unmodified buffers open. This autocommand +" deletes netrw's buffer once it's hidden (using ':q', for example) -autocmd BufNewFile *.sh so $HOME/.vim/templates/sh -autocmd BufNewFile *.sh %s/FILE:.*/\='FILE: '.expand('%:t')/e -autocmd BufNewFile *.sh exe "g/AUTHOR:.*/s//AUTHOR: C Hawley" -autocmd BufNewFile *.sh exe "g/CREATED:.*/s//CREATED: " .strftime("%Y-%m-%d") -autocmd BufWritePre,filewritepre *.sh execute "normal ma" -autocmd BufWritePre,filewritepre *.sh exe "g/REVISION:.*/s//REVISION: " .strftime("%Y-%m-%d") -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 %s/title.*/\=''.expand('%:r')/e -autocmd BufWritePre,filewritepre *.md,*.mkd execute "normal ma" -autocmd BufWritePre,filewritepre *.md,*.mkd exe "g/Updated:.*/s//Updated: " .strftime("%Y-%m-%d %H:%M") -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 - -" NetrwTreeListing readonly fix. (https://vi.stackexchange.com/a/13012) -" Per default, netrw leaves unmodified buffers open. This autocommand -" deletes netrw's buffer once it's hidden (using ':q', for example) autocmd FileType netrw setl bufhidden=delete " --------------------------------------------------------------------------------------------------------------------- @@ -296,4 +272,3 @@ autocmd FileType netrw setl bufhidden=delete " autocmd BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab - diff --git a/README.md b/README.md index 90f8317..94c10ac 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@ # dotfiles-vim -Breaking this out of my dotfiles repo to try to get a handle on multiple configurations from multiple machines. - -I also want to finally have a `.vimrc` in which I understand each and every line. After years of collecting snips and +I want to finally have a `.vimrc` in which I understand each and every line. After years of collecting snips and scraps from other people's dotfiles, I want to make sure that I am aware of what my `.vimrc` is doing. -This configuration is based heavily on the guide I found here: [Vim -Zero](https://www.oliversherouse.com/2017/08/21/vim_zero.html) which does exactly what I am aiming to do here: wipe the -slate clean and start over. +This configuration is based heavily on the guide I found here: [Vim Zero](https://www.oliversherouse.com/2017/08/21/vim_zero.html) +which does exactly what I am aiming to do here: wipe the slate clean and start over. -Whenever possible, I've noted the URL from which I found the setting or snippet. I try to insist that not everything -is self-explanatory. +Whenever possible, I've noted the URL from which I found the setting or snippet. I try to insist that not everything is self-explanatory. + +* 2024-02-13: Several changes: + * Included more comments and links about what each entry does + * Removed polyglot plugin + * Removed ALE plugin + * Removed vim-markdown plugin + * Removed netrw customizations + * Removed auto templates, changed them to snippets: + * Insert markdown header with `,md` + * Insert shell header with `,sh` -* 2020-02-13: migrated repo to castlerock