gn is a very useful command that selects the next search result. For example, if I insertfoo bar bazinto a file, move to the beginning, type /[aeiou]., and press gn, it would select oo in a visual selection. Pressing dgn would delete that and then select ar in a visual selection.However, let's say I have the following file (where [x] represents the cursor):This is some text.Blah blah blah.Lorem ipsum.Foo bar b[a]z quux.and I've searched for . . (any character, a space, then any character). Pressing dgn would delete the z q, since it's the first search result after my cursor. However, pressing gn from here now has no effect, since this motion does not wrap around back to the beginning of the file like n does.How can I make gn wrap to the first search result if there are no results after the cursor (but still have no effect (or give an error, without moving the cursor) if there are no more results in the entire file), just like the n command?After discussion in the comments: This may be system-specific. I'm running Vim 7.4.52 on Ubuntu 14.04.
How can I make the gn motion wrap to the beginning of the file?
search