Skip to content

Commit

Permalink
streak-mode: <space> to exit
Browse files Browse the repository at this point in the history
- configurable via g:sneak#streak_esc
- closes justinmk#122
  • Loading branch information
justinmk committed Jan 28, 2015
1 parent 1cbeb84 commit 565c2ef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion autoload/sneak/streak.vim
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ func! s:do_streak(s, v, reverse) "{{{

if choice == "\<Tab>" && overflow[0] > 0 "overflow => decorate next N matches
call cursor(overflow[0], overflow[1])
elseif -1 != index(["\<Esc>", "\<C-c>"], choice)
elseif (strlen(g:sneak#opt.streak_esc) && choice ==# g:sneak#opt.streak_esc)
\ || -1 != index(["\<Esc>", "\<C-c>"], choice)
return "\<Esc>" "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.
Expand Down
18 changes: 16 additions & 2 deletions doc/sneak.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand All @@ -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
-------------------------|----------------------------------------------
<space> | Exit streak-mode at the current cursor
| position.


==============================================================================
3. Features *sneak-features*
Expand Down Expand Up @@ -377,6 +386,11 @@ g:sneak#streak = 0

1 : Enable |sneak-streak-mode| if the Vim |+conceal| feature is available.

g:sneak#streak_esc = "\<space>"

Exit |sneak-streak-mode| as if <esc> 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
Expand Down
1 change: 1 addition & 0 deletions plugin/sneak.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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', "\<space>")
\ ,'prompt' : get(g:, 'sneak#prompt', '>')
\ }

Expand Down

0 comments on commit 565c2ef

Please sign in to comment.