Commit graph

52 commits

Author SHA1 Message Date
Tim Pope 4bac219cc0 Drop FUNDING.yml in favor of account-level default 2024-07-07 14:24:39 -04:00
Tim Pope 8b4435c5bb Account for Vim undo double-incrementing b:changedtick
Resolves: https://github.com/tpope/vim-repeat/issues/63
Resolves: https://github.com/tpope/vim-repeat/issues/94
Resolves: https://github.com/tpope/vim-repeat/pull/95
2024-07-07 13:00:05 -04:00
Tim Pope e0466d2b24 Bump minimum Vim version to 8.0 2024-07-07 13:00:03 -04:00
Ingo Karkat 24afe922e6 Rework error return to prevent off-by-one in Ex mode
My automated tests run Vim in silent batch mode (:help -s-ex), these also cover repeat of mappings via repeat.vim. Unfortunately, the combination of feedkeys() and :execute used in the repeat.vim implementation to return a potential caught error cause the line where the repeat mapping is executed to be increased, so for me the tests fail in a really strange way. The same problem can occur if someone uses repeats in silent batch mode (e.g. through a recorded macro) - though the source of the problem would be even harder to track down there - in my test run it at least was easily reproducible.

I raised this as a potential Vim bug in https://github.com/vim/vim/issues/7153, but Bram explained that it's a side effect of Ex mode (where empty lines make the cursor go to the next line, and as repeat#run() returns the empty String on the happy path, that's an empty line being executed). Recommendation from Bram is to pass the "x" flag for immediate execution to feedkeys() (which avoids the problem). However, in the context of repeat.vim this would mean that any errors resulting from the repeat mapping invocation would have to be caught inside repeat#run(), because they would then execute within the function's context, and not after it. Also, the "x" flag would not be supported by old Vim 7.3 and earlier.

Instead, I chose to avoid the problem by replacing the :execute with a more straightforward :call (actually an :if that tests a returned Boolean success flag), so instead of the clever direct execution of the returned :echoerr command, the error message instead is retrieved from a script-local variable via a new repeat#errmsg() getter. I use this idiom in all of my plugins through a set of utility functions (5bb32fd27a/autoload/ingo/err.vim (L38-L41)), too.
So by adding a little (well encapsulated) variable and getter, this problem can be avoided without touching the sensitive feedkeys() and try...catch logic within the plugin.
2021-01-24 22:11:08 -05:00
Tim Pope c947ad2b6a Add sponsor button 2019-11-12 19:31:06 -05:00
Anton Kochkov ae361bea99 Add vim-radical in the plugins list 2019-07-29 12:17:59 -04:00
Ingo Karkat 0b9b5e742f Make an explicit register on repeat override g:repeat_reg
As with built-in commands, this allows to override the original register on repeat, e.g. "a. uses register a instead of the original one.

One limitation is that we cannot detect whether no or the default register has been given, so an override from a non-default to the default register (e.g. via "".) is not possible.
2019-04-25 22:13:50 -04:00
Ingo Karkat 5974ea07ac Documentation fix for repeat#setreg()
Need to :execute the :silent! call to avoid that the remainder of the
command line is aborted together with the call when repeat.vim is not
installed. Otherwise, <SID>MyFunction() won't be invoked, and the
mapping does nothing.
2019-04-25 21:49:34 -04:00
Ingo Karkat eb97e729be feedkeys(..., 'i') sends keys in the wrong order in Vim 7.0/1/2
The current implementation prefers feedkeys(..., 'i') and only falls back to :normal if Vim 7.4 does not have the 'i' flag and if Vim 7.3 supports :normal with count. For Vim 8.0 (and later), and also for versions between 7.0 and 7.3.99, feedkeys(..., 'i') is used. Due to the prepending action of the 'i' flag, keys must be submitted in reverse order; that's why s is submitted before r . cnt.  Vim 7.0...7.3.99 ignore the 'i' flag, though, and append the keys, which are now in the wrong order (this only matters if a register or count is given).

Add a separate conditional branch for Vim versions before 7.3.100 that uses feedkeys() in the correct order and omits the ignored 'i' flag.
2019-04-25 21:48:12 -04:00
Tim Pope 43d2678fa5 Remove outdated plugin references 2018-07-02 15:03:55 -04:00
Tim Pope 1ea8a5325b Update installation instructions 2018-07-02 15:03:36 -04:00
Tim Pope 8fe8bde4f4 Change Markdown heading style 2018-07-02 15:03:25 -04:00
Tim Pope 8106e142df repeat.vim 1.2
* Provide <Plug> mappings.
* Enable repeating operators with custom motions.
* Assorted bug fixes.
2018-01-30 23:08:02 -05:00
Jacob Niehus 1b82cad74c Fix undo messages being hidden (#33) 2018-01-21 18:45:49 -05:00
Chris Paul 070ee90324 Remove unneeded exe in example mapping (#60) 2017-04-21 13:43:53 -04:00
Tim Pope 7a6675f092 Merge pull request #47 from orlp/master
Prevent stack trace of search errors.
2015-05-09 13:57:55 -04:00
Tim Pope 5bacc6f805 Fix bogus spaces in maps 2015-05-07 14:29:12 -04:00
Orson Peters e42a430e64 More realistic Vim error, and catch all normal exceptions. 2015-04-23 01:45:15 +02:00
Orson Peters 655dd3e2be Prevent stack trace of search errors. 2015-04-23 00:27:56 +02:00
Tim Pope c4f9f159e6 Merge pull request #46 from wellle/45-fix-feedkeys-count
Revert order of feedkeys calls to fix counts
2015-04-03 10:30:37 -04:00
Christian Wellenbrock 7568a9604b Revert order of feedkeys calls to fix counts
Since we are using the `i` flag, the feedkeys calls insert the keys
instead of appending. That's why we need to insert the second part of
the command before inserting the first part in front of it.
2015-04-03 12:30:43 +02:00
Tim Pope b01aafbd8d Merge pull request #43 from jasonkuhrt/patch-1
Update README.markdown
2015-03-07 21:28:23 -06:00
Jason Rose-Kuhrt 751b369cc3 Update README.markdown 2015-03-07 22:17:05 -05:00
Tim Pope d9fbf5a137 Merge pull request #42 from Konfekt/patch-2
remove trailing spaces in remaps
2015-02-20 14:33:20 -06:00
Konfekt 88e7d7e5c3 remove trailing spaces in remaps
Vim interprets `nmap <key> <mapping> ` as `nmap <key> <mapping><space>`. 
Here we do not want this and put `|` directly after `<mapping>`.
2015-02-20 21:28:28 +01:00
Tim Pope 4895d90a14 Merge pull request #41 from Konfekt/patch-2
more convenient remapping by using <plug> mappings
2015-02-20 14:17:44 -06:00
Konfekt cffb2e7578 more convenient remapping by using <plug> mappings
Now mappings can be remapped in `.vimrc` by
`nnoremap <key> <Plug>(RepeatUndoLine)`
and disablabled in `.vimrc` by
`nnoremap <SID>(DisableRepeatUndoLine) <Plug>(RepeatUndoLine)`
2015-02-20 21:14:38 +01:00
Tim Pope b06684a195 Merge pull request #39 from wellle/feedkeys-i
Pass flag 'i' to feedkeys() call
2015-01-31 14:17:00 -06:00
Christian Wellenbrock ad89be240f Pass flag 'i' to feedkeys() calls
Only fall back to :norm for versions 7.3.100 <= v < 7.4.601
2015-01-28 16:51:28 +01:00
Tim Pope bd3b517235 Merge pull request #37 from justinmk/fix703
Fix condition for Vim <= 7.3
2015-01-19 16:20:08 -06:00
Justin M. Keyes 006694e0f5 Fix condition for Vim <= 7.3 2015-01-19 17:09:05 -05:00
Tim Pope 7f09c18d2e Merge pull request #36 from justinmk/norm
Use :norm for Vim 7.3.100 or later
2015-01-19 14:42:53 -06:00
Justin M. Keyes 193f4866df Use :norm for Vim 7.3.100 or later
Fixes #23
2015-01-17 09:55:08 -05:00
Tim Pope b6bdd0f2d0 Merge pull request #35 from wilywampa/invalidate
Fix invalidate() being overridden by autocmd
2015-01-15 18:49:10 -06:00
Jacob Niehus 80261bc531 Fix invalidate() being overridden by autocmd 2015-01-10 18:47:31 -07:00
d125q 5eba0f19c8 Make repeat#wrap open a fold if &foldopen contains 'all'
Closes #31.
2014-12-08 19:48:38 -05:00
Tim Pope 2a3c5f8e3c Allow repeating operators with custom motions
Closes #8.
2013-12-24 10:44:09 -05:00
Tim Pope a81bef7603 repeat.vim 1.1
* Fix adding trailing spaces when 've' is not empty.
* Don't increment b:changedtick, offer invalidate instead.
* Support repetition with original register.
* Don't clobber existing U map.
* Respect 'foldopen' on undo.
* Allow customizing all mappings.
2013-01-01 00:17:12 -05:00
Ingo Karkat 8ee7450812 Allow customizing all mappings
f1d0fbbdf4 allowed customizing the .
mapping by making the implementation function publicly accessible. Let's
do the same to s:wrap(), so that the other mappings (u, U, <C-R>) can be
extended, too.

(Personally, I'd like to have undo / redo stop and beep at the last
saved position, to avoid that I accidentally undo beyond the saved state
even though I didn't intend to.)
2012-12-31 16:06:45 -05:00
Ingo Karkat aeb3d6cd89 Documentation fix for repeat#setreg()
Need to :execute the :silent! call to avoid that the remainder of the
command line is aborted together with the call when repeat.vim is not
installed. Otherwise, <SID>MyFunction() won't be invoked, and the
mapping does nothing.
2012-12-01 16:05:05 -05:00
Andrew Radev d8f7fe7598 Go back to using feedkeys()
Since there seems to be a bug with "norm" in Vim prior to 7.3.100,
better go back to using feedkeys.

The repeat call can still be remapped by using something like:

  nnoremap . :call repeat#run(v:count)<bar>call feedkeys('`.', 'n')<cr>
2012-11-24 00:23:14 -05:00
Andrew Radev f1d0fbbdf4 Allow for some additional post-processing
This commit makes the s:repeat function public as repeat#run to allow
manual remapping for customization.
2012-11-03 16:21:28 -04:00
Tim Pope 613eb1c812 Respect 'foldopen' on undo
Closes #9.
2012-08-22 11:30:12 -04:00
Tim Pope d75a544b78 Don't clobber existing U map
Closes #6.
2012-05-02 19:13:33 -04:00
Ingo Karkat 2914f11f74 Support repetition with original register
For commands that take an optional register (like p/P), Vim uses the
same register on repetition. This enhancement allows the same for custom
mappings, which need to call repeat#setreg() before repeat#set(). (No
changes for the vast majority of mappings that don't use registers.) It
even supports repeat of the expression register, with the expression
being re-evaluated on repeat.
2012-03-10 14:18:41 -05:00
Ingo Karkat 476c28084e Don't increment b:changedtick, offer invalidate instead
repeat#set() so far automatically incremented b:changedtick. Problems
with this:
1. The way that was done clobbered the expression register "=.
2. It causes the "readonly" warning and "Cannot make changes" error in
   readonly/nomodifiable buffers, so mappings that don't modify anything
   cannot be repeated there.
3. It's actually not needed most of the time, because many user mappings
   and all repeatable Vim built-in normal mode commands I know (with the
   exception of yank with cpo+=y) actually do modify the buffer
   themselves.

For the exceptional case where the user has a set of related mappings,
one that repeats naturally (e.g. a custom operator, via g@), and one
that invokes repeat#set(), and both do not modify the buffer, a new
function repeat#invalidate() is offered. This should be called by the
former mapping, and all is well.
2012-03-10 14:16:58 -05:00
xaizek 1118a8324f Fix adding trailing spaces when 've' is not empty
The problem appears when cursor is positioned after line end, thus
running p command (even with empty "-register) causes Vim to add spaces
from line end until cursor.
2012-02-23 16:41:35 -05:00
Tim Pope cdffdd4381 Clarify copyright 2011-08-29 16:11:07 -04:00
Tim Pope ecab7ca1b7 Fix heading 2011-08-29 02:47:25 -04:00
Tim Pope bef6db85d9 Add a README 2011-08-29 02:14:52 -04:00