From 565c2ef37b3a05c33466805dc1fefa19669bb793 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 28 Jan 2015 02:18:12 -0500 Subject: [PATCH] streak-mode: to exit - configurable via g:sneak#streak_esc - closes #122 --- autoload/sneak/streak.vim | 3 ++- doc/sneak.txt | 18 ++++++++++++++++-- plugin/sneak.vim | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/autoload/sneak/streak.vim b/autoload/sneak/streak.vim index 11e5011..7b67ea5 100644 --- a/autoload/sneak/streak.vim +++ b/autoload/sneak/streak.vim @@ -92,7 +92,8 @@ func! s:do_streak(s, v, reverse) "{{{ if choice == "\" && overflow[0] > 0 "overflow => decorate next N matches call cursor(overflow[0], overflow[1]) - elseif -1 != index(["\", "\"], choice) + elseif (strlen(g:sneak#opt.streak_esc) && choice ==# g:sneak#opt.streak_esc) + \ || -1 != index(["\", "\"], choice) return "\" "exit streak-mode. elseif !mappedtoNext && !has_key(s:matchmap, choice) "press _any_ invalid key to escape. call feedkeys(choice) "exit streak-mode and fall through to Vim. diff --git a/doc/sneak.txt b/doc/sneak.txt index 882e57c..67ca828 100644 --- a/doc/sneak.txt +++ b/doc/sneak.txt @@ -53,9 +53,11 @@ Type dzad to delete from the cursor to the first instance of "ad": > ------------------------------------------------------------------------------ 2.1 Default mappings *sneak-defaults* + Note: See |sneak-mappings| to change these mappings. + Sneak default NORMAL-mode mappings: - Normal-mode key sequence | Description + Normal-Mode Key Sequence | Description -------------------------|---------------------------------------------- s{char}{char} | Go to the next occurrence of {char}{char} S{char}{char} | Go to the previous occurrence of {char}{char} @@ -79,7 +81,7 @@ Sneak default NORMAL-mode mappings: Sneak default VISUAL-mode mappings: - Visual-mode key sequence | Description + Visual-Mode Key Sequence | Description -------------------------|---------------------------------------------- s{char}{char} | Go to the next occurrence of {char}{char} Z{char}{char} | Go to the previous occurrence of {char}{char} @@ -92,6 +94,13 @@ Sneak default VISUAL-mode mappings: s | Go to the [count]'th next match (NOTE above) S | Go to the [count]'th previous match (NOTE above) +STREAK-mode mappings (|sneak-streak-mode|): + + Key Sequence | Description + -------------------------|---------------------------------------------- + | Exit streak-mode at the current cursor + | position. + ============================================================================== 3. Features *sneak-features* @@ -377,6 +386,11 @@ g:sneak#streak = 0 1 : Enable |sneak-streak-mode| if the Vim |+conceal| feature is available. +g:sneak#streak_esc = "\" + + Exit |sneak-streak-mode| as if were pressed. + https://github.com/justinmk/vim-sneak/issues/122 + g:sneak#target_labels = "asdfghjkl;qwertyuiopzxcvbnm/ASDFGHJKL:QWERTYUIOPZXCVBNM?" List of 1-character "labels" used by streak-mode to decorate the target diff --git a/plugin/sneak.vim b/plugin/sneak.vim index 89c4067..b6a1d98 100644 --- a/plugin/sneak.vim +++ b/plugin/sneak.vim @@ -25,6 +25,7 @@ func! sneak#init() \ ,'map_netrw' : get(g:, 'sneak#map_netrw', 1) \ ,'map_esc' : get(g:, 'sneak#map_esc', 0) \ ,'streak' : get(g:, 'sneak#streak', 0) && (v:version >= 703) && has("conceal") + \ ,'streak_esc' : get(g:, 'sneak#streak_esc', "\") \ ,'prompt' : get(g:, 'sneak#prompt', '>') \ }