[Is this a BUG?] exe normal "?\r\n" changes the direction of the search to backwards from the ":" command line, but not from within a function.

19 views
Skip to first unread message

Shlomi Fish

unread,
Feb 27, 2012, 4:08:45 PM2/27/12
to vim_dev
Hi all.

«exe normal "?\r\n"» changes the direction of the search to backwards
from the ":" command line, but not from within a function.

For example, with this vimscript file (called test.vim):

[QUOTE]
function! Test_back_search()
exe "normal ?\r\n"
endfunction
[/QUOTE]

Then after I press "*" and do «:exe normal "?\r\n"» (from the ex-
command line) then the direction of the search changes to backwards
but if I do «:call Test_back_search()» then it search backwards once,
but further presses on "n" yield forward searches. I don't understand
why it should not work properly in both cases, and it seems like a
bug.

This interferes with further development on this Vim plugin:

https://github.com/shlomif/add-to-word-search.vim

I tried it both with an old gvim 7.3 from Mercurial (
changeset: 3132:fb6b43d55773
tag: tip
user: Bram Moolenaar <br...@vim.org>
date: Fri Sep 30 18:35:57 2011 +0200
summary: Added tag v7-3-329 for changeset ec901ddc84d5

) and with vim-X11-7.3.444-1.mga2 from Mageia Linux 2. It happens with
vim -u NONE -U NONE too.

Regards,

-- Shlomi Fish

James McCoy

unread,
Feb 27, 2012, 4:22:31 PM2/27/12
to vim_dev
On Mon, Feb 27, 2012 at 01:08:45PM -0800, Shlomi Fish wrote:
> Hi all.
>
> «exe normal "?\r\n"» changes the direction of the search to backwards
> from the ":" command line, but not from within a function.
>
> For example, with this vimscript file (called test.vim):
>
> [QUOTE]
> function! Test_back_search()
> exe "normal ?\r\n"
> endfunction
> [/QUOTE]

This is likely related to ":help function-search-undo".

--
James
GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <jame...@jamessan.com>

signature.asc

Christian Brabandt

unread,
Feb 27, 2012, 4:22:45 PM2/27/12
to vim_dev
Hi Shlomi!

I think, what you are observing is described at

:h function-search-undo

regards,
Christian

Reply all
Reply to author
Forward
0 new messages