0

vim have many things that the manual describe just as "search forward".

1. Search commands search-commands / /{pattern}[/]<CR> Search forward for the [count]'th occurrence of {pattern} |exclusive|. [...] star E348 E349 * Search forward for the [count]'th occurrence of the word nearest to the cursor. The word used for the 

Yet, only the ones entered with the / command will show up on the command history.

How can i have all the other "search" commands (*, #, g*, gd, etc) be part of a common history pool?

For example, let's say i am in a .c file. I press * a few times to search some terms. Then I open the .h file... now I can only search for the last term by pression n and there's no way to search for the previous ones I have just searched for! if i have searched then by using /, then when moving files i could use /<UP> and search for them again.

1
  • 3
    Wait a second, I can * a word and then do /<up> and make it show up. Commented Jun 14, 2024 at 13:01

2 Answers 2

1

All the actions you mention (/, *, #, g*) populate the search history.

You can navigate the search history using:

  • /Ctrl+p and /Ctrl+n
  • /Up and /Down or using
  • q/
4
  • Only the last one is present on history. If you add two terms ("one", then "two") via *, only "two" will be in the history. "one" will not be in history at all. Commented Jun 14, 2024 at 13:59
  • 3
    This is not what I observe on my 9.1 version of gVim :-| Could you share your version number (:version)? Could you share the result of the q/ command? Commented Jun 14, 2024 at 14:01
  • 2
    vivan, and Friedrich, you are correct. I do get the history just fine with q/ but not with /<up>... i might have something fiddling with that. So it's a user problem and the history is there just fine. ...i also misunderstood the help text. assumed "mapping" to mean things in commands in Normal mode. Commented Jun 14, 2024 at 14:05
  • Thanks for your feedback. I indeed believe that the mapping is not related. I suspect it is related to the behavior of the command triggered by a map family of command (that must be very fast). I confirm I have the full history with /<Up> and /<Down>. something odd seems to appear on your end. If you slightly update the search string <Up> and <Down> restrict themselves to search with the same prefix. Maybe could you try <C-p> and <C-n> that navigate the history without taking into account the actual content of the search buffer. Commented Jun 14, 2024 at 14:10
0

from :help history

 cmdline-history history The command-lines that you enter are remembered in a history table. You can recall them with the up and down cursor keys. There are actually five history tables: - one for ':' commands - one for search strings [...] Notes: [...] - All searches are put in the search history, including the ones that come from commands like "*" and "#". But for a mapping, only the last search is remembered (to avoid that long mappings trash the history). 

So, I am guessing the answer is no. :(

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.