diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-14 22:20:05 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-14 22:20:05 +1200 |
commit | c11c409c60603e6735833a2a57cf90c6e83567e6 (patch) | |
tree | 8e36a3e8de08c09842c408f91f07a07fa7b1300a | |
parent | Move autocmd definitions out of augroup block (diff) | |
download | dotfiles-c11c409c60603e6735833a2a57cf90c6e83567e6.tar.gz dotfiles-c11c409c60603e6735833a2a57cf90c6e83567e6.zip |
Replace and refactor Vim paste plugins
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | vim/autoload/paste_insert.vim | 14 | ||||
m--------- | vim/bundle/paste_open | 0 | ||||
-rw-r--r-- | vim/plugin/paste_insert.vim | 6 | ||||
-rw-r--r-- | vim/vimrc | 17 |
5 files changed, 29 insertions, 11 deletions
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 <buffer> + \ set nopaste paste? + \|autocmd! paste_insert + autocmd paste_insert InsertEnter <buffer> + \ set paste paste? + \|autocmd paste_insert InsertLeave <buffer> + \ doautocmd paste_insert User +endfunction diff --git a/vim/bundle/paste_open b/vim/bundle/paste_open deleted file mode 160000 -Subproject 79ee83eac32dbadf722df687e65f07d75a2f8ea 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#() @@ -1254,10 +1254,6 @@ xmap <Leader>n <Esc><Leader>ngv nnoremap <Leader>N \ :<C-U>set ruler! ruler?<CR> xmap <Leader>N <Esc><Leader>Ngv -"" Leader,p toggles paste mode -nnoremap <Leader>p - \ :<C-U>set paste! paste?<CR> -xmap <Leader>p <Esc><Leader>pgv "" Leader,w toggles soft wrapping nnoremap <Leader>w \ :<C-U>setlocal wrap! wrap?<CR> @@ -1317,6 +1313,15 @@ nnoremap <Leader>L \ :<C-U>ToggleFlagLocal colorcolumn +1<CR> xmap <Leader>L <Esc><Leader>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 <Leader>p + \ :<C-U>PasteInsert<CR> + " 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>? "" Leader,. runs the configured make program into the location list nnoremap <Leader>. \ :<C-U>lmake!<CR> -"" Leader,o opens a line below in paste mode -nmap <Leader>o <Plug>(PasteOpenBelow) -"" Leader,O opens a line above in paste mode -nmap <Leader>O <Plug>(PasteOpenAbove) "" Leader,q formats the current paragraph nnoremap <Leader>q gqap "" Leader,r acts as a replacement operator |