Skip to content

Commit

Permalink
Disable "clever-s" by default
Browse files Browse the repository at this point in the history
To enable "clever-s", add this to your .vimrc:
    let g:sneak#s_next = 1
  • Loading branch information
justinmk committed Mar 31, 2014
1 parent d01cb12 commit 5d10683
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Sneak is invoked with `s` followed by exactly two characters:

* Press `sab` to **move the cursor** immediately to the next instance of the text "ab".
* Additional matches, if any, are highlighted until the cursor is moved.
* Press `s` *or* `;` to go to the next match.
* Press `3s` *or* `3;` to skip to the third match from the current position.
* Press `;` to go to the next match (or `s` again, if `s_next` is enabled; see [`:help sneak`](doc/sneak.txt)).
* Press `3;` to skip to the third match from the current position.
* Press `ctrl-o` or ``` `` ``` to go back to the starting point.
* This is a built-in Vim motion; Sneak adds to Vim's [jumplist](http://vimdoc.sourceforge.net/htmldoc/motion.html#jumplist)
*only* on `s` invocation—not repeats—so you can
Expand All @@ -53,7 +53,7 @@ via `z` (because `s` is taken by surround.vim).
* Press `d;` to delete up to the next match.
* Press `4d;` to delete up to the *fourth* next match.
* Press `ysz))]` to surround in brackets up to `))`.
* Press `s` *or* `;` to go to the next `))`.
* Press `;` to go to the next `))`.
* Press `gUz\}` to upper-case the text from the cursor until the next instance
of the literal text `\}`
* Press `.` to repeat the `gUz\}` operation.
Expand Down
12 changes: 6 additions & 6 deletions doc/sneak.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,16 @@ g:sneak#t_reset = 1
you invoke f or t. See the README.md FAQ regarding "f-enhancement"
plugins.

g:sneak#s_next = 1
g:sneak#s_next = 0

0 : Disable "clever-s" behavior. Use |;| and |,| to go to the next or
previous match.

1 : Immediately after invoking Sneak, press "s" _again_ to go to the
next match (or "S" for the previous match); this behavior persists
until you move the cursor. This feature is called "clever-s" because
it originated in the clever-f[3] plugin.
Note: You can also use |;| and |,| at any time, as usual.
1 : Enable the "clever-s" feature (similar to the clever-f plugin[3]).
It works like this: immediately after invoking Sneak, press "s" _again_
to go to the next match, or "S" for the previous match. This behavior
persists until you move the cursor.
Note: You can still use |;| and |,| as usual.

g:sneak#textobject_z = 1

Expand Down
2 changes: 1 addition & 1 deletion plugin/sneak.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func! sneak#init()
"options v-- for backwards-compatibility
let g:sneak#opt = { 'f_reset' : get(g:, 'sneak#nextprev_f', get(g:, 'sneak#f_reset', 1))
\ ,'t_reset' : get(g:, 'sneak#nextprev_t', get(g:, 'sneak#t_reset', 1))
\ ,'s_next' : get(g:, 'sneak#s_next', 1)
\ ,'s_next' : get(g:, 'sneak#s_next', 0)
\ ,'textobject_z' : get(g:, 'sneak#textobject_z', 1)
\ ,'use_ic_scs' : get(g:, 'sneak#use_ic_scs', 0)
\ ,'map_netrw' : get(g:, 'sneak#map_netrw', 1)
Expand Down
23 changes: 7 additions & 16 deletions tests/test.vader
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,10 @@ Expect:
###########################################################
# clever-s _not_ in streak-mode

Execute (init clever-s):
let g:sneak#s_next = 1
call sneak#init()

Given:
abcdef abcdef abcdef
abcdef abcdef abcdef
Expand Down Expand Up @@ -502,6 +506,9 @@ Expect:
abcdxef abcdef abcdef
abcdef abcdef abcdef

Execute (unset clever-s):
let g:sneak#s_next = 0
call sneak#init()
###########################################################

Given:
Expand Down Expand Up @@ -571,27 +578,11 @@ Expect:
# abcdef ``=2Bd-a3/+ =QWEOIJ/+ ~~~!!! ! { } abc AAaab
# abcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+

# force-exit via <Space> because feedkeys() in do_streak() breaks macros/Vader
Do (clever-s, streak-mode):
sab\<Space>2six

Expect:
abcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+
`=QWEOIJ/+ ~~~!!! ! { } abc AAaxab
abcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+

# TODO: this is working, but fails in Vader
#Do (clever-s, visual-mode, streak-mode):
# vsabsd
#
#Expect:
# bc AAaab
# abcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+

# TODO: this is working, but fails in Vader
#Do (clever-s, backwards clever-s, visual-mode, streak-mode):
# jvsabsssZd
#
#Expect:
# abcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+
# bcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+
Expand Down

0 comments on commit 5d10683

Please sign in to comment.