commit a76f898a7219c32168eb4657d3fbc91674919eec
parent 2b920ec77364ac0b55806965d3d91ab910ef95c1
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Wed, 5 Feb 2020 21:58:55 +0100
vim: vimrc switch now preserves args, switches to window if open, etc.
Former-commit-id: 07da28fd391dbfc45836a96356186edb9468b472
Diffstat:
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/vim/autoload/drop_vimrc.vim b/vim/autoload/drop_vimrc.vim
@@ -0,0 +1,11 @@
+" Drop to vimrc without changing args
+" (because :drop clobbers args)
+function! drop_vimrc#DropToFoldedVimrc()
+ let s:args = expand("##")
+ drop $MYVIMRC
+ setlocal foldmethod=marker foldlevel=0
+ argdelete *
+
+ exe "argadd ".s:args
+ unlet s:args
+endfunction
diff --git a/vim/plugin/drop_vimrc.vim b/vim/plugin/drop_vimrc.vim
@@ -0,0 +1 @@
+command! DropToFoldedVimrc silent call drop_vimrc#DropToFoldedVimrc()
diff --git a/vim/vimrc b/vim/vimrc
@@ -766,14 +766,14 @@ nnoremap zs :exe "set foldlevel=".foldlevel(line('.'))<CR>
" Config edit mappings
" Why :drop? It uses the file if it's already open.
-nnoremap <C-E><C-V> :drop $MYVIMRC<CR>zXgg
-nnoremap <C-E><C-A> :drop $MYVIMRC<CR>zXgg/Autocommands {{<CR>:noh<CR>za
-nnoremap <C-E><C-C> :drop $MYVIMRC<CR>zXgg/Commands {{<CR>:noh<CR>za
-nnoremap <C-E><C-E> :drop $MYVIMRC<CR>zXgg/Editor {{<CR>:noh<CR>za
-nnoremap <C-E><C-G> :drop $MYVIMRC<CR>zXgg/General {{<CR>:noh<CR>za
-nnoremap <C-E><C-M> :drop $MYVIMRC<CR>zXgg/Mappings {{<CR>:noh<CR>za
-nnoremap <C-E><C-P><C-I> :drop $MYVIMRC<CR>zXgg/Plugins {{<CR>:noh<CR>za/Installation {{<CR>:noh<CR>za
-nnoremap <C-E><C-P><C-C> :drop $MYVIMRC<CR>zXgg/Plugins {{<CR>:noh<CR>za/Config {{<CR>:noh<CR>za
+nnoremap <C-E><C-V> :DropToFoldedVimrc<CR>zXgg
+nnoremap <C-E><C-A> :DropToFoldedVimrc<CR>zXgg/^" Autocommands {{<CR>:noh<CR>za
+nnoremap <C-E><C-C> :DropToFoldedVimrc<CR>zXgg/Commands {{<CR>:noh<CR>za
+nnoremap <C-E><C-E> :DropToFoldedVimrc<CR>zXgg/Editor {{<CR>:noh<CR>za
+nnoremap <C-E><C-G> :DropToFoldedVimrc<CR>zXgg/General {{<CR>:noh<CR>za
+nnoremap <C-E><C-M> :DropToFoldedVimrc<CR>zXgg/Mappings {{<CR>:noh<CR>za
+nnoremap <C-E><C-P><C-I> :DropToFoldedVimrc<CR>zXgg/Plugins {{<CR>:noh<CR>za/Installation {{<CR>:noh<CR>za
+nnoremap <C-E><C-P><C-C> :DropToFoldedVimrc<CR>zXgg/Plugins {{<CR>:noh<CR>za/Config {{<CR>:noh<CR>za
nmap <C-E><C-L> <Plug>VimcolorEdit
" Yank to clipboard