Compare commits

...

2 Commits

Author SHA1 Message Date
8a0582e0d5 Merge pull request 'Sweeping changes to vim environment' (#1) from 20241213 into master
Reviewed-on: #1
2024-02-13 11:32:43 -05:00
5613555960 Sweeping changes to vim environment
Details in README.md
2024-02-13 11:29:43 -05:00
6 changed files with 170 additions and 177 deletions

View File

@@ -1,6 +1,7 @@
:insert
# title # title
Updated:
--- ---
## Summary ## Summary

View File

@@ -1,4 +1,3 @@
:insert
#!/usr/bin/env bash #!/usr/bin/env bash
#=============================================================================== #===============================================================================
# #

55
.vim/vim-keys-help.md Normal file
View File

@@ -0,0 +1,55 @@
# vim-keys
A cheat sheet for my vim customizations
---
## Spelling
`<ctrl>-p` - auto-complete spelling suggestions
`<F10>` - toggle spellcheck
## Highlights
`<leader><leader>` - turn off search highlight
`<Leader>C` - toggle row/column cursor
## Buffers
`<ctrl>H` - to move to previous BUFFER
`<ctrl>L` - to move to next BUFFER
`<ctrl>J` - to move to lower PANE
`<ctrl>K` - to move to upper PANE
`<leader>s` - to save buffer
`<leader>c` - to close buffer
`<leader>a` - to abandon unsaved buffer
`<leader>x` - bring up the copy buffer
`<F5>` - refresh buffer
`<leader>r` - open registers
## FZF
`<leader>f` - open FZF files
`<leader>b` - open FZF buffers
## Text bubbling (http://vimcasts.org/episodes/bubbling-text/)
After text selection (`<ctrl-v>`)
`<ctrl>k` - bubble up
`<ctrl>j` - bubble down
## Date and Time stamps
`<F2>` - insert %Y-%m-%d %H:%M:%S
`<F3>` - insert %Y-%m-%d %a
`<F4>` - insert %H:%M
## Snippets
pre-made files inserted from `.vim/templates`
`,sh` - insert shell header
`,md` - insert markdown header
`,ban` - insert ASCII banner

View File

@@ -1,42 +0,0 @@
# /home/phansible/vim-keys
## Highlights
`<F10>` - turn off spellcheck highlights
`<leader></>` - turn off search highlight
`<Leader>c` - toggle row/column cursor
## Buffers & Panes
`<ctrl>-H` - to move to previous BUFFER
`<ctrl>-L` - to move to next BUFFER
`<ctrl>-J` - to move to lower PANE
`<ctrl>-K` - to move to upper PANE
`<leader>-s` - to save buffer
`<leader>-c` - to close buffer
`<leader>-x` - bring up the copy buffer
`<F5>` - refresh buffer
## FZF
`<leader>-f` - open files
`;` - open buffers
## Text bubbling (http://vimcasts.org/episodes/bubbling-text/)
After text selection (`<ctrl-v>`)
`<ctrl>-k` - bubble up
`<ctrl>-j` - bubble down
## Date and Time stamps
`<F2>` - insert %Y-%m-%d %H:%M:%S
`<F3>` - insert %Y-%m-%d %a
`<F4>` - insert %H:%M
---
`<ctrl>-p` - auto-complete spelling suggestions

223
.vimrc
View File

@@ -1,20 +1,20 @@
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> .vimrc " ==> .vimrc
set nocompatible " be iMproved, required set nocompatible " be iMproved, required
set number " turn on line numbers set number " turn on line numbers
set relativenumber " lines are numbered relative to current line set relativenumber " lines are numbered relative to current line
set scrolloff=8 " number of lines to keep above and below the cursor set scrolloff=8 " number of lines to keep above and below the cursor
set belloff=all " no sound/flash on errors set belloff=all " no sound/flash on errors
set autoread " set to auto read when a file is changed from the outside set autoread " set to auto read when a file is changed from the outside
set cursorcolumn " highlight current column set cursorcolumn " highlight current column
set cursorline " highlight current row set cursorline " highlight current row
set incsearch " make search act like search in modern browsers set incsearch " make search act like search in modern browsers
set showmatch " show matching brackets when text indicator is over them set showmatch " show matching brackets when text indicator is over them
set term=xterm-256color " LOTS of colors set term=xterm-256color " LOTS of colors
set path+=** " Search Globally set path+=** " Search Globally
set wildmenu set wildmenu
autocmd! bufwritepost .vimrc source ~/.vimrc " When vimrc is edited, reload it autocmd! bufwritepost .vimrc source ~/.vimrc " When vimrc is edited, reload it
@@ -31,6 +31,9 @@ augroup end
syntax enable syntax enable
filetype plugin on 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 " ==> 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 set formatoptions-=ro " Turn off autoinsert of comment char on newline
" Text Wrapping " Text Wrapping
set textwidth=120 set textwidth=120 " Set textwidth
set colorcolumn= " disable color column set colorcolumn= " disable colorzing <textwidth> column
set nowrap set nowrap " turn off word wrapping at <textwidth>
" Search and Substitute " Search and Substitute
set gdefault " use global flag by default in s: commands set gdefault " use global flag by default in s: commands
@@ -58,50 +61,45 @@ set shiftwidth=4
set expandtab set expandtab
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Plugins " ==> Plugins with VimPlug
" A minimalist Vim plugin manager
" https://github.com/junegunn/vim-plug
"" Installation with VimPlug
if has("win32") if has("win32")
call plug#begin('~/vimfiles/plugged') call plug#begin('~/vimfiles/plugged')
else else
call plug#begin('~/.vim/plugged') call plug#begin('~/.vim/plugged')
endif endif
""" Basics " Think of sensible.vim as one step above 'nocompatible' mode: a universal set of defaults that (hopefully) everyone can agree on
" ...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' Plug 'tpope/vim-sensible'
" Syntax highlights for markdown " One stop shop for vim colorschemes
Plug 'tpope/vim-markdown' " https://github.com/flazz/vim-colorschemes
" one stop shop for vim color schemes.
Plug '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', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim' 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' Plug 'tpope/vim-fugitive'
" vim.vinegar " ALE displays warnings and errors in files being edited before being saved back to the filesystem
Plug 'tpope/vim-vinegar' " https://github.com/dense-analysis/ale
" Linter
Plug 'dense-analysis/ale' Plug 'dense-analysis/ale'
" Syntax highlights for multiple languages
"Plug 'sheerun/vim-polyglot'
call plug#end() call plug#end()
" ---------------------------------------------------------------------------------------------------------------------
" ==> Plugin options
"
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Colors " ==> Colors
" " Term GUI Colors
"set termguicolors " Testing different colorschemes
" Only the last uncommented colorscheme will be used
"colorscheme slate "colorscheme slate
"colorscheme marklar "colorscheme marklar
"colorscheme automation "colorscheme automation
@@ -112,7 +110,6 @@ colorscheme advantage
highlight cursorcolumn cterm=NONE ctermbg=black ctermfg=white guibg=darkred guifg=white highlight cursorcolumn cterm=NONE ctermbg=black ctermfg=white guibg=darkred guifg=white
"highlight visual cterm=NONE ctermbg=darkred 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 " In split windows - active buffer status bar is yellow, inactive is black
"hi statuslinenc ctermbg=gray ctermfg=black "hi statuslinenc ctermbg=gray ctermfg=black
"hi statusline ctermbg=yellow ctermfg=green "hi statusline ctermbg=yellow ctermfg=green
@@ -135,56 +132,71 @@ set statusline+=\ c:%c " cursor column
set statusline+=\ %P " percent through file set statusline+=\ %P " percent through file
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" => Keymaps: Doing more things at once " => Keymaps: Highlights
" turn off search highlight " <leader><leader> to turn off search highlight
nnoremap <leader><C-_> :nohls <enter> nnoremap <leader><leader> :nohls <enter>
" toggle row/column cursor
nnoremap <Leader>c :set cursorline! cursorcolumn!<CR> " <leader>C to toggle row/column highlight
nnoremap <Leader>C :set cursorline! cursorcolumn!<CR>
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps: Buffers & Panes " ==> Keymaps: Buffers & Panes
" <ctrl>-H to move to previous BUFFER " <ctrl>H to move to previous BUFFER
nnoremap <C-H> :bp <enter> nnoremap <C-H> :bp <enter>
" <ctrl>-L to move to next BUFFER
" <ctrl>L to move to next BUFFER
nnoremap <C-L> :bn <enter> nnoremap <C-L> :bn <enter>
" <ctrl>-J to move to lower PANE
" <ctrl>J to move to lower PANE
nnoremap <C-J> <C-W><C-J> nnoremap <C-J> <C-W><C-J>
" <ctrl>-K to move to upper PANE
" <ctrl>K to move to upper PANE
nnoremap <C-K> <C-W><C-K> nnoremap <C-K> <C-W><C-K>
" <leader>-s to save buffer " <leader> b to open FZF buffers
map <leader>b :Buffers<CR>
" <leader>s to save buffer
nnoremap <Leader>s :w <enter> nnoremap <Leader>s :w <enter>
" <leader>-c to close buffer
" <leader>c to close buffer
nnoremap <Leader>c :bd <enter> nnoremap <Leader>c :bd <enter>
" bring up the copy buffer " <leader>a to abandon buffer
nnoremap <Leader>a :bd! <enter>
" <leader>x to bring up the copy buffer
noremap <Leader>x "+ noremap <Leader>x "+
" <F5> to refresh buffer
" <F5> to refresh buffer
nnoremap <F5> <C-R>:checktime <CR> nnoremap <F5> <C-R>:checktime <CR>
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps: With ripgrep and FZF " ==> Keymaps
" <leader> f to open files " <leader> f to open FZF files
map <Leader>f :Files<CR> map <Leader>f :Files<CR>
" search buffers
nmap ; :Buffers<CR> " <leader>r to open registers
map <leader>r :registers<CR>
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps: Text bubbling (http://vimcasts.org/episodes/bubbling-text/) " ==> Keymaps: Text bubbling (http://vimcasts.org/episodes/bubbling-text/)
" Bubble single lines " Bubble single lines
nmap <C-k> ddkP nmap <C-k> ddkP
nmap <C-j> ddp nmap <C-j> ddp
" Bubble multiple lines
" Bubble multiple lines
vmap <C-k> xkP`[V`] vmap <C-k> xkP`[V`]
vmap <C-j> xp`[V`] vmap <C-j> xp`[V`]
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps: More sane movement keys " ==> Keymaps: Movement keys
" Navigate according to displayed lines, not physical lines
nnoremap j gj nnoremap j gj
nnoremap k gk nnoremap k gk
@@ -195,32 +207,33 @@ imap <F2> <C-R>=strftime("%Y-%m-%d %H:%M:%S")<CR>
imap <F3> <C-R>=strftime("%Y-%m-%d %a")<CR> imap <F3> <C-R>=strftime("%Y-%m-%d %a")<CR>
imap <F4> <C-R>=strftime("%H:%M")<CR> imap <F4> <C-R>=strftime("%H:%M")<CR>
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> 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 " ==> Spellcheck
set spell spelllang=en_us " Toggle spell check highlights with <F10>
" Toggle spell check with F10
nnoremap <F10> :setlocal spell! spelllang=en_us<CR> nnoremap <F10> :setlocal spell! spelllang=en_us<CR>
" auto-complete spelling suggestions with <ctrl-p> " auto-complete spelling suggestions with <ctrl-p>
set complete+=kspell 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) " (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) " Vim Colors: (http://alvinalexander.com/linux/vi-vim-editor-color-scheme-syntax)
hi clear SpellBad hi clear SpellBad
@@ -232,63 +245,26 @@ hi SpellBad cterm=underline ctermbg=black ctermfg=red
hi SpellCap cterm=underline ctermbg=black ctermfg=red hi SpellCap cterm=underline ctermbg=black ctermfg=red
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Snippets " ==> Snippets
" Pasting pre-made things " Pasting pre-made things
" section banner " section banner
nnoremap ,ban :-1read $HOME/.vim/templates/banner<CR>jA nnoremap ,ban :-1read $HOME/.vim/templates/banner<CR>jA
" section begin/end " section begin/end
nnoremap ,begend :-1read $HOME/.vim/templates/begend<CR>jA nnoremap ,begend :-1read $HOME/.vim/templates/begend<CR>jA
" --------------------------------------------------------------------------------------------------------------------- " section shell script header
" ==> Templates nnoremap ,shead :-1read $HOME/.vim/templates/sh<CR>jA
" Doing special things with certain filetypes
" section markdown file header
nnoremap ,md :-1read $HOME/.vim/templates/md<CR>jA
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> 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 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 BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab

View File

@@ -1,16 +1,21 @@
# dotfiles-vim # dotfiles-vim
Breaking this out of my dotfiles repo to try to get a handle on multiple configurations from multiple machines. I want to finally have a `.vimrc` in which I understand each and every line. After years of collecting snips and
I also 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. 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 This configuration is based heavily on the guide I found here: [Vim Zero](https://www.oliversherouse.com/2017/08/21/vim_zero.html)
Zero](https://www.oliversherouse.com/2017/08/21/vim_zero.html) which does exactly what I am aiming to do here: wipe the which does exactly what I am aiming to do here: wipe the slate clean and start over.
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 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.
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