Cleaned up .vimrc

Re-arranged things to make it easier to see if I'm over-writing
keybindings.  Added comments to areas that didn't have any.  Reverted
some keybindings I found I wasn't using.

Also changed the Banner template to use double-quotes instead of
hash marks since I only ever use it in my .vimrc
This commit is contained in:
2024-02-28 11:31:55 -05:00
parent de4af48ee6
commit 36184cddd4
2 changed files with 101 additions and 123 deletions

View File

@@ -1,3 +1,3 @@
# --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
# ==> " ==>
# "

218
.vimrc
View File

@@ -1,21 +1,66 @@
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> .vimrc " ==> .vimrc
set nocompatible " be iMproved, required " ---------------------------------------------------------------------------------------------------------------------
set number " turn on line numbers " ==> Some settings from Vim Zero: https://www.oliversherouse.com/posts/vim_zero.html
set relativenumber " lines are numbered relative to current line "
set scrolloff=10 " number of lines to keep above and below the cursor syntax enable
set belloff=all " no sound/flash on errors filetype plugin on
" General
let mapleader = '\'
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 belloff=all " no sound/flash on errors
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 formatoptions-=ro " Turn off autoinsert of comment char on newline
set showmatch " show matching brackets when text indicator is over them set hidden " Allow background buffers without saving
set nolist " do not show invisible characters
set term=xterm-256color " LOTS of colors set nocompatible " be iMproved, required
set number " turn on line numbers
set path+=** " Search Globally set path+=** " Search Globally
set wildmenu set relativenumber " lines are numbered relative to current line
set ruler " show cursor poition
set scrolloff=10 " number of lines to keep above and below the cursor
set showmatch " show matching brackets when text indicator is over them
set splitright " Split to right by default
set term=xterm-256color " LOTS of colors
set wildmenu " enhanced command line completion
" Text Wrapping
set textwidth=120 " Set textwidth
set colorcolumn= " disable colorzing <textwidth> column
set nowrap " turn off word wrapping at <textwidth>
" Search and Substitute
set gdefault " use global flag by default in s: commands
set hlsearch " highlight searches
set ignorecase " ignore case in searches
set incsearch " make search act like search in modern browsers
set smartcase " don't ignore capitals in searches
" Tabs
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
" ---------------------------------------------------------------------------------------------------------------------
" => 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
autocmd! bufwritepost .vimrc source ~/.vimrc " When vimrc is edited, reload it autocmd! bufwritepost .vimrc source ~/.vimrc " When vimrc is edited, reload it
@@ -28,15 +73,17 @@ augroup BgHighlight
autocmd WinLeave * set norelativenumber autocmd WinLeave * set norelativenumber
augroup end augroup end
syntax enable " Toggle invisible characters with <F5>
filetype plugin on set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
noremap <F5> :set list!<CR>
inoremap <F5> <C-o>:set list!<CR>
cnoremap <F5> <C-c>:set list!<CR>
" Enable Omnicomplete features " Enable Omnicomplete features
set omnifunc=syntaxcomplete#Complete set omnifunc=syntaxcomplete#Complete
" Personal Notes settings " Personal Notes settings
" export NOTES_DIR=<your notes directory> " export NOTES_DIR=<your notes directory> before use
" before use
" Go to index of notes and set working directory to my notes " Go to index of notes and set working directory to my notes
nnoremap <leader>ww :e $NOTES_DIR/Index.md<CR>:cd $NOTES_DIR<CR> nnoremap <leader>ww :e $NOTES_DIR/Index.md<CR>:cd $NOTES_DIR<CR>
@@ -47,32 +94,6 @@ nnoremap <leader>ww :e $NOTES_DIR/Index.md<CR>:cd $NOTES_DIR<CR>
command! -nargs=1 Ngrep vimgrep "<args>" $NOTES_DIR/**/*.md | copen command! -nargs=1 Ngrep vimgrep "<args>" $NOTES_DIR/**/*.md | copen
nnoremap <leader>[ :Ngrep nnoremap <leader>[ :Ngrep
" ---------------------------------------------------------------------------------------------------------------------
" ==> 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
set formatoptions-=ro " Turn off autoinsert of comment char on newline
" Text Wrapping
set textwidth=120 " Set textwidth
set colorcolumn= " disable colorzing <textwidth> column
set nowrap " turn off word wrapping at <textwidth>
" 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 with VimPlug " ==> Plugins with VimPlug
" A minimalist Vim plugin manager " A minimalist Vim plugin manager
@@ -102,10 +123,6 @@ Plug 'junegunn/fzf.vim'
" https://github.com/tpope/vim-fugitive " https://github.com/tpope/vim-fugitive
Plug 'tpope/vim-fugitive' Plug 'tpope/vim-fugitive'
" 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'
" Vim surround " Vim surround
" I tried to do this from scratch, but it seems this is the best alternative " I tried to do this from scratch, but it seems this is the best alternative
" https://github.com/tpope/vim-surround " https://github.com/tpope/vim-surround
@@ -128,41 +145,41 @@ call plug#end()
" ==> Plugin Options " ==> Plugin Options
" Options and overrides for installed plugins " Options and overrides for installed plugins
" Vim Markdown " = Vim Markdown
" Markdown syntax highlighting for specified languages " = Markdown syntax highlighting for specified languages
let g:markdown_fenced_languages = ['html', 'python', 'ini', 'vim', 'bash', 'yaml'] let g:markdown_fenced_languages = ['html', 'python', 'ini', 'vim', 'bash', 'yaml']
" Set default conceallevel to hide links and some formatting " = Set default conceallevel to hide links and some formatting
set conceallevel=0 set conceallevel=0
" strikethrough " = strikethrough
let g:vim_markdown_strikethrough = 1 let g:vim_markdown_strikethrough = 1
" follow anchors - allow <ge> to follow anchors just like links " = follow anchors - allow <ge> to follow anchors just like links
let g:vim_markdown_follow_anchor = 1 let g:vim_markdown_follow_anchor = 1
" multi-line bullets in markdown " = multi-line bullets in markdown
" [Reference](https://vimdoc.sourceforge.net/htmldoc/change.html#fo-table) " = [Reference](https://vimdoc.sourceforge.net/htmldoc/change.html#fo-table)
" j - remove a comment leader when joining lines. " j - remove a comment leader when joining lines.
" l - long lines are not broken in insert mode " l - long lines are not broken in insert mode
" n - Recognize numbered lists " n - Recognize numbered lists
" r - Continue comments when pressing Enter " r - Continue comments when pressing Enter
" t - autowrap lines using text width value " t - autowrap lines using text width value
autocmd FileType markdown set formatoptions=jlnrt autocmd FileType markdown set formatoptions=jlnrt
" Open folds by default " = Open folds by default
au BufWinEnter * normal zR au BufWinEnter * normal zR
" ALE
"let b:ale_linters = ['markdownlint', 'vale']
"let b:ale_fixers = ['prettier']
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Colors " ==> Colors
" Term GUI Colors " Term GUI Colors
" Testing different colorschemes " Testing different colorschemes
" Only the last uncommented colorscheme will be used " Only the last uncommented colorscheme will be used
" This is typically a history of the schemes I've used
"colorscheme slate "colorscheme slate
"colorscheme marklar "colorscheme marklar
colorscheme automation "colorscheme automation
"colorscheme advantage "colorscheme advantage
colorscheme industry
" cursorcolumn
hi cursorcolumn cterm=NONE ctermbg=black ctermfg=white hi cursorcolumn cterm=NONE ctermbg=black ctermfg=white
" visual mode colors
hi visual cterm=NONE ctermbg=darkyellow ctermfg=white hi visual cterm=NONE ctermbg=darkyellow ctermfg=white
set fillchars=vert:│,fold:┈,diff:┈ set fillchars=vert:│,fold:┈,diff:┈
@@ -170,27 +187,10 @@ set fillchars=vert:│,fold:┈,diff:┈
hi StatusLine ctermfg=white ctermbg=darkgreen cterm=bold hi StatusLine ctermfg=white ctermbg=darkgreen cterm=bold
hi StatusLineNC ctermfg=white ctermbg=darkyellow cterm=none hi StatusLineNC ctermfg=white ctermbg=darkyellow cterm=none
" ---------------------------------------------------------------------------------------------------------------------
" => 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: Highlights " => Keymaps: Highlights
" <leader><leader> to turn off search highlight " <leader><space> to turn off search highlight
nnoremap <leader><space> :nohls <enter> nnoremap <leader><space> :nohls <enter>
" <leader>C to toggle row/column highlight " <leader>C to toggle row/column highlight
@@ -198,43 +198,34 @@ nnoremap <leader>C :set cursorline! cursorcolumn!<CR>
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps: Buffers & Panes " ==> Keymaps: Buffers & Panes
" BUFFERS with ctrl
" PANES with <leader>
" when possible
" <c-h/l> to navigate BUFFERS " <c-h/l> to navigate BUFFERS
nnoremap <c-h> :bp <enter> nnoremap <c-h> :bp <enter>
nnoremap <c-l> :bn <enter> nnoremap <c-l> :bn <enter>
" <c-b> to open FZF buffers " <leader>b to open FZF buffers
map <c-b> :Buffers<CR> map <leader>b :Buffers<CR>
" <leader>a to abandon buffer
nnoremap <leader>a :bd! <enter>
" <leader>c to close buffer
nnoremap <leader>c :bd <enter>
" <c-s> to save buffer " <c-s> to save buffer
nnoremap <c-s> :w <enter> nnoremap <c-s> :w<CR>
" <c-q> to quit vim
nnoremap <c-q> :q <enter>
" <c-a> to abandon buffer
nnoremap <c-a> :bd! <enter>
" <c-c>c to close buffer
nnoremap <c-c> :bd <enter>
" <c-x> to bring up the copy buffer " <c-x> to bring up the copy buffer
noremap <c-x> "+ noremap <c-x> "+
" <F5> to refresh buffer
nnoremap <F5> <c-r>:checktime <CR>
" <leader>h/j/k/l to navigate PANES " <leader>h/j/k/l to navigate PANES
nnoremap <leader>h <c-w><c-h> nnoremap <leader>h <c-w><c-h>
nnoremap <leader>l <c-w><c-l> nnoremap <leader>l <c-w><c-l>
nnoremap <leader>j <c-w><c-j> nnoremap <leader>j <c-w><c-j>
nnoremap <leader>k <c-w><c-k> nnoremap <leader>k <c-w><c-k>
" <leader>c to close pane " <leader>x to close pane
nnoremap <leader>c <c-w>q nnoremap <leader>x <c-w>q
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps " ==> Keymaps
@@ -268,21 +259,8 @@ nnoremap k gk
imap <F2> <C-R>=strftime("%Y-%m-%d %H:%M:%S")<CR> 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("%Y-%m-%d")<CR>
" ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps: Autoclosing
" Autoclose brackets, parens...etc
" from: https://stackoverflow.com/a/34992101
"inoremap " ""<left>
"inoremap ' ''<left>
"inoremap ( ()<left>
"inoremap [ []<left>
"inoremap { {}<left>
"inoremap {<CR> {<CR>}<ESC>O
"inoremap {;<CR> {<CR>};<ESC>O
" ---------------------------------------------------------------------------------------------------------------------
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Spellcheck " ==> Spellcheck
@@ -318,11 +296,12 @@ autocmd BufRead,BufNewFile *.txt setlocal spell
" 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
hi clear SpellCap hi clear SpellCap
hi clear SpellErrors
hi clear SpellLocal hi clear SpellLocal
hi clear SpellRare hi clear SpellRare
hi SpellBad cterm=underline ctermbg=black ctermfg=red hi SpellBad cterm=underline ctermbg=black ctermfg=red
hi SpellCap cterm=underline ctermbg=black ctermfg=red hi SpellCap cterm=underline ctermbg=black ctermfg=magenta
hi SpellLocal cterm=underline ctermbg=black ctermfg=gray
hi SpellRare cterm=underline ctermbg=black ctermfg=gray
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Templates: markdown documents (.md) " ==> Templates: markdown documents (.md)
@@ -331,10 +310,9 @@ autocmd BufNewFile *.md so $HOME/.vim/templates/md
autocmd BufNewFile *.md %s/filename/\=expand('%:t:r')/g autocmd BufNewFile *.md %s/filename/\=expand('%:t:r')/g
autocmd BufNewFile *.md exe "g/^- Created :.*/s//- Created : " .strftime("%Y-%m-%d") autocmd BufNewFile *.md exe "g/^- Created :.*/s//- Created : " .strftime("%Y-%m-%d")
autocmd BufNewFile *.md exe "normal Go" autocmd BufNewFile *.md exe "normal Go"
autocmd BufWritePre,filewritepre *.md execute "normal ma" autocmd BufWritePre,filewritepre *.md execute "normal! ma"
autocmd BufWritePre,filewritepre *.md exe "g/^- Updated :.*/s//- Updated : " .strftime("%Y-%m-%d %H:%M") "autocmd BufWritePre,filewritepre *.md exe "g/^- Updated :.*/s//- Updated : " .strftime("%Y-%m-%d %H:%M")
autocmd bufWritePost,filewritepost *.md execute "normal `a" autocmd BufWritePost,filewritepost *.md execute "normal! `a"
" --------------------------------------------------------------------------------------------------------------------- " ---------------------------------------------------------------------------------------------------------------------
" ==> Templates: shell scripts (.sh) " ==> Templates: shell scripts (.sh)