From 8617207a46ba9d4ac030a39ccf497e7a861c4dbb Mon Sep 17 00:00:00 2001 From: chawley Date: Mon, 26 Feb 2024 15:56:08 -0500 Subject: [PATCH] Buffer and Pane navigation Changed keybindings so `` generally operates on panes and `` generally operates on buffers. Also adjusted some colors. --- .vim/vim-keys-help.md | 71 ------------------------- .vimrc | 117 +++++++++++++++++++++++------------------- 2 files changed, 64 insertions(+), 124 deletions(-) delete mode 100644 .vim/vim-keys-help.md diff --git a/.vim/vim-keys-help.md b/.vim/vim-keys-help.md deleted file mode 100644 index c60a630..0000000 --- a/.vim/vim-keys-help.md +++ /dev/null @@ -1,71 +0,0 @@ -# vim-keys - -A cheat sheet for my vim customizations - ---- - -## Macros - -* `qq` - record macro -* `@` - replay macro - -## Spelling - -* `]s` - move to next misspelled word -* `[s` - move to previous misspelled word -* `z=` - suggest correction -* `-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 -* `` - open FZF files -* `b` - open FZF buffers - -## Editing - -* - autocomplete filename (insert mode) -* gf - go to file (if exists) (normal mode) - -## [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/.vimrc b/.vimrc index 9de70bc..62e1bd5 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=10 " 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=10 " 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,9 +31,18 @@ augroup end syntax enable filetype plugin on +" Personal Notes settings +" export NOTES_DIR= +" before use -" Open my personal helpfile -nmap h :e $HOME/.vim/vim-keys-help.md +" Go to index of notes and set working directory to my notes +nnoremap ww :e $NOTES_DIR/Index.md:cd $NOTES_DIR + +" [ to grep inside Notes files +" I got the idea from here [step 6: search contents of your notes](https://www.edwinwenink.xyz/posts/42-vim_notetaking/#step-6-search-contents-of-your-notes) +" but I'm not sold on the idea yet. +command! -nargs=1 Ngrep vimgrep "" $NOTES_DIR/**/*.md | copen +nnoremap [ :Ngrep " --------------------------------------------------------------------------------------------------------------------- " ==> From Vim Zero: https://www.oliversherouse.com/2017/08/21/vim_zero.html @@ -146,14 +155,13 @@ au BufWinEnter * normal zR colorscheme automation "colorscheme advantage -"highlight colorcolumn ctermbg=darkyellow guibg=darkyellow -"highlight VertSplit ctermbg=black guibg=black ctermfg=darkgray guifg=darkgray -highlight cursorcolumn cterm=NONE ctermbg=black ctermfg=white guibg=darkred guifg=white -"highlight visual cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white +hi cursorcolumn cterm=NONE ctermbg=black ctermfg=white +hi visual cterm=NONE ctermbg=darkyellow ctermfg=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 +set fillchars=vert:│,fold:┈,diff:┈ +" In split windows - active buffer status bar is green, inactive is yellow +hi StatusLine ctermfg=white ctermbg=darkgreen cterm=bold +hi StatusLineNC ctermfg=white ctermbg=darkyellow cterm=none " --------------------------------------------------------------------------------------------------------------------- " => Statusline @@ -183,60 +191,63 @@ nnoremap C :set cursorline! cursorcolumn! " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps: Buffers & Panes +" BUFFERS with ctrl +" PANES with +" when possible -" H to move to previous BUFFER -nnoremap :bp +" to navigate BUFFERS +nnoremap :bp +nnoremap :bn -" L to move to next BUFFER -nnoremap :bn +" to open FZF buffers +map :Buffers -" J to move to lower PANE -nnoremap +" to save buffer +nnoremap :w -" K to move to upper PANE -nnoremap +" to quit vim +nnoremap :q -" b to open FZF buffers -map b :Buffers +" to abandon buffer +nnoremap :bd! -" s to save buffer -nnoremap s :w +" c to close buffer +nnoremap :bd -" q to quit vim -nnoremap q :q - -" c to close buffer -nnoremap c :bd - -" a to abandon buffer -nnoremap a :bd! - -" x to bring up the copy buffer -noremap x "+ +" to bring up the copy buffer +noremap "+ " to refresh buffer -nnoremap :checktime +nnoremap :checktime + +" h/j/k/l to navigate PANES +nnoremap h +nnoremap l +nnoremap j +nnoremap k + +" c to close pane +nnoremap c q " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps -" f to open FZF files -map f :Files +" to open FZF files map :Files -" r to open registers -map r :registers +" to open registers +map :registers " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps: Text bubbling (http://vimcasts.org/episodes/bubbling-text/) " Bubble single lines -nmap ddkP -nmap ddp +nmap ddkP +nmap ddp " Bubble multiple lines -vmap xkP`[V`] -vmap xp`[V`] +vmap xkP`[V`] +vmap xp`[V`] " --------------------------------------------------------------------------------------------------------------------- " ==> Keymaps: Movement keys