aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-08-30 13:55:50 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-08-30 13:55:50 +1200
commita7736f06933091323651ed245c58f9103f1a93dd (patch)
treedb89fc5375194a6c77c052b89d21036f7ed325ea
parentMerge branch 'release/v1.64.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-a7736f06933091323651ed245c58f9103f1a93dd.tar.gz
dotfiles-a7736f06933091323651ed245c58f9103f1a93dd.zip
Merge branch 'release/v1.65.0'v1.65.0
* release/v1.65.0: Bump VERSION Add visual_block_suspend_wrap.vim plugin
-rw-r--r--VERSION4
-rw-r--r--vim/plugin/visual_block_suspend_wrap.vim43
2 files changed, 45 insertions, 2 deletions
diff --git a/VERSION b/VERSION
index 1f70db18..e1e9348a 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v1.64.0
-Wed Aug 29 23:31:09 UTC 2018
+tejr dotfiles v1.65.0
+Thu Aug 30 01:55:50 UTC 2018
diff --git a/vim/plugin/visual_block_suspend_wrap.vim b/vim/plugin/visual_block_suspend_wrap.vim
new file mode 100644
index 00000000..75b87060
--- /dev/null
+++ b/vim/plugin/visual_block_suspend_wrap.vim
@@ -0,0 +1,43 @@
+"
+" visual_block_suspend_wrap.vim: If 'wrap' is enabled, switch it off after the
+" first movement in visual block mode, and put it back after the first
+" movement after it's left. My kingdom for a VisualEnter event...
+"
+if exists('g:visual_block_suspend_wrap') || &compatible
+ finish
+endif
+if !exists('##CursorMoved')
+ finish
+endif
+let g:loaded_visual_block_suspend_wrap = 1
+
+" Flag for whether we've suspended 'wrap'
+let s:wrap_suspended = 0
+
+" Function for checking mode and suspending or restoring 'wrap', if applicable
+function! s:Check() abort
+
+ " If this is visual block mode...
+ if mode() ==# "\<C-V>"
+
+ " ...and 'wrap' is set, suspend it and flag that we did.
+ if &wrap
+ setlocal nowrap
+ let s:wrap_suspended = 1
+ endif
+
+ " If it's some other mode, and we've suspended 'wrap' and it's not on,
+ " switch it back on and clear the flag
+ elseif s:wrap_suspended && !&wrap
+ setlocal wrap
+ let s:wrap_suspended = 0
+ endif
+
+endfunction
+
+" Check the mode after each CursorMoved event, because there isn't a way to
+" check for entering or leaving visual mode specifically
+augroup visual_block_suspend_wrap
+ autocmd!
+ autocmd CursorMoved * call s:Check()
+augroup END