[UPDATE][VIM] Move mappings to different files
Because a lot of my mappings use the <Leader> key, this is the only file that *must* be loaded before all the others, otherwise the value of leader when the script is read will be erroneous. I also tried to use `git write-tree` and `git commit-tree` to emulate a manual octopus merge to preserve the line history for each file. But honestly that gave a graph that was too ugly for a history that really did not need that amount of accountability. However it is a fun exercise, and I recommend to everyone to try it at least once. See Raymond Chen's blog `The Old New Thing`, with the post titled `How to split out pieces of a file while preserving git line history: The hard way with commit-tree`, for an explanation.
This commit is contained in:
parent
1d58d25015
commit
a3d8ef9a63
16
vim/.vim/after/plugin/mappings/fugitive.vim
Normal file
16
vim/.vim/after/plugin/mappings/fugitive.vim
Normal file
|
@ -0,0 +1,16 @@
|
|||
" Visual bindings for merging diffs as in normal mode
|
||||
xnoremap dp :diffput<cr>
|
||||
xnoremap do :diffget<cr>
|
||||
|
||||
" Git add current file
|
||||
nnoremap <Leader>ga :Git add %:p<CR><CR>
|
||||
" Open status window
|
||||
nnoremap <Leader>gs :Gstatus<CR>
|
||||
" Open diff view of current buffer: the up/left window is the current index
|
||||
nnoremap <Leader>gd :Gdiffsplit!<CR>
|
||||
" Open current file log in new tab, populate its location list with history
|
||||
nnoremap <Leader>gl :sp<CR><C-w>T:Gllog --follow -- %:p<CR>
|
||||
" Open a buffer to the left with blame information
|
||||
nnoremap <Leader>gb :Gblame<CR>
|
||||
" Commit staged changes, open a new tab just for it
|
||||
nnoremap <Leader>gc :Gcommit -v -q<CR>
|
20
vim/.vim/after/plugin/mappings/fzf.vim
Normal file
20
vim/.vim/after/plugin/mappings/fzf.vim
Normal file
|
@ -0,0 +1,20 @@
|
|||
" Only git-tracked files, Vim needs to be in a Git repository
|
||||
nnoremap <Leader>fg :GFiles<CR>
|
||||
" All files
|
||||
nnoremap <Leader>ff :Files<CR>
|
||||
" Currently open buffers
|
||||
nnoremap <Leader>fb :Buffers<CR>
|
||||
" Buffer history
|
||||
nnoremap <Leader>fh :History<CR>
|
||||
" Tags in buffer
|
||||
nnoremap <Leader>ft :BTags<CR>
|
||||
" Tags in all project files
|
||||
nnoremap <Leader>fT :Tags<CR>
|
||||
" Snippets for the current fileytpe (using Ultisnips)
|
||||
nnoremap <Leader>fs :Snippets<CR>
|
||||
" All available commands
|
||||
nnoremap <Leader>f: :Commands<CR>
|
||||
" All commits (using fugitive)
|
||||
nnoremap <Leader>fc :Commits<CR>
|
||||
" All commits for the current buffer (using fugitive)
|
||||
nnoremap <Leader>fC :BCommits<CR>
|
15
vim/.vim/after/plugin/mappings/misc.vim
Normal file
15
vim/.vim/after/plugin/mappings/misc.vim
Normal file
|
@ -0,0 +1,15 @@
|
|||
" Yank until the end of line with Y, to be more consistent with D and C
|
||||
nnoremap Y y$
|
||||
|
||||
" Mappings for working with vimrc
|
||||
nnoremap <Leader>ev :edit $MYVIMRC<CR>
|
||||
nnoremap <Leader>es :source $MYVIMRC<CR>
|
||||
|
||||
" Run make silently, then skip the 'Press ENTER to continue'
|
||||
noremap <Leader>m :silent! :make! \| :redraw!<CR>
|
||||
|
||||
" Remove search-highlighting
|
||||
noremap <Leader><Leader> :nohls<CR>
|
||||
|
||||
" Explicit map for vim-cheat40 which seems to fail because of my <Nop> map
|
||||
map <Leader>? :<C-u>Cheat40<CR>
|
11
vim/.vim/after/plugin/mappings/qf.vim
Normal file
11
vim/.vim/after/plugin/mappings/qf.vim
Normal file
|
@ -0,0 +1,11 @@
|
|||
" Next and previous in quick-fix list
|
||||
nmap <Leader>fn <Plug>(qf_qf_next)
|
||||
nmap <Leader>fp <Plug>(qf_qf_previous)
|
||||
|
||||
" Next and previous in location list
|
||||
nmap <Leader>ln <Plug>(qf_loc_next)
|
||||
nmap <Leader>lp <Plug>(qf_loc_previous)
|
||||
|
||||
" Toggle quick-fix and location lists
|
||||
nmap <Leader>tf <Plug>(qf_qf_toggle)
|
||||
nmap <Leader>tl <Plug>(qf_loc_toggle)
|
7
vim/.vim/after/plugin/mappings/unimpaired.vim
Normal file
7
vim/.vim/after/plugin/mappings/unimpaired.vim
Normal file
|
@ -0,0 +1,7 @@
|
|||
" Better fr layout mappings for vim-unimpaired and other '[' and ']' commands
|
||||
nmap ( [
|
||||
nmap ) ]
|
||||
omap ( [
|
||||
omap ) ]
|
||||
xmap ( [
|
||||
xmap ) ]
|
6
vim/.vim/plugin/mappings/leader.vim
Normal file
6
vim/.vim/plugin/mappings/leader.vim
Normal file
|
@ -0,0 +1,6 @@
|
|||
" Map leader to space (needs the noremap trick to avoid moving the cursor)
|
||||
nnoremap <Space> <Nop>
|
||||
let mapleader=" "
|
||||
|
||||
" Map localleader to '!' (if I want to filter text, I use visual mode)
|
||||
let maplocalleader="!"
|
92
vim/.vimrc
92
vim/.vimrc
|
@ -324,98 +324,6 @@ let g:fastfold_fold_command_suffixes=[
|
|||
" }}}
|
||||
" }}}
|
||||
|
||||
" Mappings {{{
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Miscellaneous mappings {{{
|
||||
""""""""""""""""""""""""
|
||||
" Yank until the end of line with Y, to be more consistent with D and C
|
||||
nnoremap Y y$
|
||||
|
||||
" Map leader to space (needs the noremap trick)
|
||||
nnoremap <Space> <Nop>
|
||||
let mapleader=" "
|
||||
" Map localleader to '!' (if I want to filter text, I use visual mode)
|
||||
let maplocalleader="!"
|
||||
|
||||
" Mappings for working with this file.
|
||||
map <Leader>ev :edit $MYVIMRC<CR>
|
||||
map <Leader>es :source $MYVIMRC<CR>
|
||||
|
||||
" Run make silently, then skip the 'Press ENTER to continue'
|
||||
noremap <Leader>m :silent! :make! \| :redraw!<CR>
|
||||
|
||||
" Remove search-highlighting
|
||||
noremap <Leader><Leader> :nohls<CR>
|
||||
|
||||
" Better fr layout mappings for vim-unimpaired and other '[' and ']' commands
|
||||
nmap ( [
|
||||
nmap ) ]
|
||||
omap ( [
|
||||
omap ) ]
|
||||
xmap ( [
|
||||
xmap ) ]
|
||||
|
||||
" Map for vim-cheat40 which seems to fail because of my <Space> to <Nop> map
|
||||
map <Leader>? :<C-u>Cheat40<CR>
|
||||
" }}}
|
||||
|
||||
" Mapping for quickfix bindings {{{
|
||||
"""""""""""""""""""""""""""""""
|
||||
" Next and previous in quick-fix list
|
||||
nmap <Leader>fn <Plug>(qf_qf_next)
|
||||
nmap <Leader>fp <Plug>(qf_qf_previous)
|
||||
" Next and previous in location list
|
||||
nmap <Leader>ln <Plug>(qf_loc_next)
|
||||
nmap <Leader>lp <Plug>(qf_loc_previous)
|
||||
" Toggle quick-fix and location lists
|
||||
nmap <Leader>tf <Plug>(qf_qf_toggle)
|
||||
nmap <Leader>tl <Plug>(qf_loc_toggle)
|
||||
" }}}
|
||||
|
||||
" Fuzzy file finder bindings {{{
|
||||
""""""""""""""""""""""""""""
|
||||
" Only git-tracked files, Vim needs to be in a Git repository
|
||||
nmap <Leader>fg :GFiles<CR>
|
||||
" All files
|
||||
nmap <Leader>ff :Files<CR>
|
||||
" Currently open buffers
|
||||
nmap <Leader>fb :Buffers<CR>
|
||||
" Buffer history
|
||||
nmap <Leader>fh :History<CR>
|
||||
" Tags in buffer
|
||||
nmap <Leader>ft :BTags<CR>
|
||||
" Tags in all project files
|
||||
nmap <Leader>fT :Tags<CR>
|
||||
" Snippets for the current fileytpe (using Ultisnips)
|
||||
nmap <Leader>fs :Snippets<CR>
|
||||
" All available commands
|
||||
nmap <Leader>f: :Commands<CR>
|
||||
" All commits (using fugitive)
|
||||
nmap <Leader>fc :Commits<CR>
|
||||
" All commits for the current buffer (using fugitive)
|
||||
nmap <Leader>fC :BCommits<CR>
|
||||
" }}}
|
||||
|
||||
" Git and diff mappings {{{
|
||||
"""""""""""""""""""""""
|
||||
" Visual bindings for merging diffs as in normal mode
|
||||
xnoremap dp :diffput<cr>
|
||||
xnoremap do :diffget<cr>
|
||||
" Git add current file
|
||||
nnoremap <Leader>ga :Git add %:p<CR><CR>
|
||||
" Open status window
|
||||
nnoremap <Leader>gs :Gstatus<CR>
|
||||
" Open diff view of current buffer: the up/left window is the current index
|
||||
nnoremap <Leader>gd :Gdiffsplit!<CR>
|
||||
" Open current file log in new tab, populate its location list with history
|
||||
nnoremap <Leader>gl :sp<CR><C-w>T:Gllog --follow -- %:p<CR>
|
||||
" Open a buffer to the left with blame information
|
||||
nnoremap <Leader>gb :Gblame<CR>
|
||||
" Commit staged changes, open a new tab just for it
|
||||
nnoremap <Leader>gc :Gcommit -v -q<CR>
|
||||
" }}}
|
||||
" }}}
|
||||
|
||||
" Import settings when inside a git repository {{{
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
let git_settings=system("git config --get vim.settings")
|
||||
|
|
Loading…
Reference in a new issue