Buffer and Pane navigation

Changed keybindings so `<leader>` generally operates on panes and `<ctrl>` generally operates
on buffers.  Also adjusted some colors.
This commit is contained in:
2024-02-26 15:56:08 -05:00
parent fc2e6f39d4
commit 8617207a46
2 changed files with 64 additions and 124 deletions

117
.vimrc
View File

@@ -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=<your notes directory>
" before use
" Open my personal helpfile
nmap <leader>h :e $HOME/.vim/vim-keys-help.md<CR>
" 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>
" <leader>[ 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 "<args>" $NOTES_DIR/**/*.md | copen
nnoremap <leader>[ :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 <leader>C :set cursorline! cursorcolumn!<CR>
" ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps: Buffers & Panes
" BUFFERS with ctrl
" PANES with <leader>
" when possible
" <ctrl>H to move to previous BUFFER
nnoremap <C-H> :bp <enter>
" <c-h/l> to navigate BUFFERS
nnoremap <c-h> :bp <enter>
nnoremap <c-l> :bn <enter>
" <ctrl>L to move to next BUFFER
nnoremap <C-L> :bn <enter>
" <c-b> to open FZF buffers
map <c-b> :Buffers<CR>
" <ctrl>J to move to lower PANE
nnoremap <C-J> <C-W><C-J>
" <c-s> to save buffer
nnoremap <c-s> :w <enter>
" <ctrl>K to move to upper PANE
nnoremap <C-K> <C-W><C-K>
" <c-q> to quit vim
nnoremap <c-q> :q <enter>
" <leader> b to open FZF buffers
map <leader>b :Buffers<CR>
" <c-a> to abandon buffer
nnoremap <c-a> :bd! <enter>
" <leader>s to save buffer
nnoremap <leader>s :w <enter>
" <c-c>c to close buffer
nnoremap <c-c> :bd <enter>
" <leader>q to quit vim
nnoremap <leader>q :q <enter>
" <leader>c to close buffer
nnoremap <leader>c :bd <enter>
" <leader>a to abandon buffer
nnoremap <leader>a :bd! <enter>
" <leader>x to bring up the copy buffer
noremap <leader>x "+
" <c-x> to bring up the copy buffer
noremap <c-x> "+
" <F5> to refresh buffer
nnoremap <F5> <C-R>:checktime <CR>
nnoremap <F5> <c-r>:checktime <CR>
" <leader>h/j/k/l to navigate PANES
nnoremap <leader>h <c-w><c-h>
nnoremap <leader>l <c-w><c-l>
nnoremap <leader>j <c-w><c-j>
nnoremap <leader>k <c-w><c-k>
" <leader>c to close pane
nnoremap <leader>c <c-w>q
" ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps
" <leader>f to open FZF files
map <leader>f :Files<CR>
" <leader><leader> to open FZF files
map <leader><leader> :Files<CR>
" <leader>r to open registers
map <leader>r :registers<CR>
" <c-r> to open registers
map <c-r> :registers<CR>
" ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps: Text bubbling (http://vimcasts.org/episodes/bubbling-text/)
" Bubble single lines
nmap <C-k> ddkP
nmap <C-j> ddp
nmap <c-k> ddkP
nmap <c-j> ddp
" Bubble multiple lines
vmap <C-k> xkP`[V`]
vmap <C-j> xp`[V`]
vmap <c-k> xkP`[V`]
vmap <c-j> xp`[V`]
" ---------------------------------------------------------------------------------------------------------------------
" ==> Keymaps: Movement keys