From c11c409c60603e6735833a2a57cf90c6e83567e6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 14 Jun 2019 22:20:05 +1200 Subject: Replace and refactor Vim paste plugins --- .gitmodules | 3 --- vim/autoload/paste_insert.vim | 14 ++++++++++++++ vim/bundle/paste_open | 1 - vim/plugin/paste_insert.vim | 6 ++++++ vim/vimrc | 17 +++++++++-------- 5 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 vim/autoload/paste_insert.vim delete mode 160000 vim/bundle/paste_open create mode 100644 vim/plugin/paste_insert.vim diff --git a/.gitmodules b/.gitmodules index 86bad115..77c7e443 100644 --- a/.gitmodules +++ b/.gitmodules @@ -29,9 +29,6 @@ [submodule "vim/bundle/insert_timeout"] path = vim/bundle/insert_timeout url = https://sanctum.geek.nz/code/vim-insert-timeout.git -[submodule "vim/bundle/paste_open"] - path = vim/bundle/paste_open - url = https://sanctum.geek.nz/code/vim-paste-open.git [submodule "vim/bundle/put_blank_lines"] path = vim/bundle/put_blank_lines url = https://sanctum.geek.nz/code/vim-put-blank-lines.git diff --git a/vim/autoload/paste_insert.vim b/vim/autoload/paste_insert.vim new file mode 100644 index 00000000..fe7cb35f --- /dev/null +++ b/vim/autoload/paste_insert.vim @@ -0,0 +1,14 @@ +augroup paste_insert + autocmd! +augroup END + +function! paste_insert#() abort + autocmd! paste_insert + autocmd paste_insert CursorHold,CursorMoved,User + \ set nopaste paste? + \|autocmd! paste_insert + autocmd paste_insert InsertEnter + \ set paste paste? + \|autocmd paste_insert InsertLeave + \ doautocmd paste_insert User +endfunction diff --git a/vim/bundle/paste_open b/vim/bundle/paste_open deleted file mode 160000 index 79ee83ea..00000000 --- a/vim/bundle/paste_open +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 79ee83eac32dbadf722df687e65f07d75a2f8eaf diff --git a/vim/plugin/paste_insert.vim b/vim/plugin/paste_insert.vim new file mode 100644 index 00000000..be578746 --- /dev/null +++ b/vim/plugin/paste_insert.vim @@ -0,0 +1,6 @@ +if exists('loaded_paste_insert') + finish +endif +let loaded_paste_insert = 1 +command! -bar PasteInsert + \ call paste_insert#() diff --git a/vim/vimrc b/vim/vimrc index 124e3af7..f5dfc8fd 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1254,10 +1254,6 @@ xmap n ngv nnoremap N \ :set ruler! ruler? xmap N Ngv -"" Leader,p toggles paste mode -nnoremap p - \ :set paste! paste? -xmap p pgv "" Leader,w toggles soft wrapping nnoremap w \ :setlocal wrap! wrap? @@ -1317,6 +1313,15 @@ nnoremap L \ :ToggleFlagLocal colorcolumn +1 xmap L Lgv +" This mapping uses my paste_insert.vim plugin to queue up automatic commands +" for the next insert operation. It's still pretty new. It replaces my old +" paste_open.vim plugin which did this only for opening new lines, and which +" kept confusing me. I'm hoping this will be better. + +"" Leader,p prepares the next insert for paste mode +nnoremap p + \ :PasteInsert + " These mappings are for managing filetypes. The first one uses the " :ReloadFileType command that was defined much earlier in this file for " application in the vimrc reload command. @@ -1494,10 +1499,6 @@ nnoremap ? "" Leader,. runs the configured make program into the location list nnoremap . \ :lmake! -"" Leader,o opens a line below in paste mode -nmap o (PasteOpenBelow) -"" Leader,O opens a line above in paste mode -nmap O (PasteOpenAbove) "" Leader,q formats the current paragraph nnoremap q gqap "" Leader,r acts as a replacement operator -- cgit v1.2.3