The ex command $ navigates to the first character of the last line. Therefore, when doing a backwards search it skips the line it's currently on. How do I navigate to the last character with ex, or alternatively search for the last occurrence of a regular expression?Example:$ cd -- $(mktemp --directory)$ printf '%s\n' foo bar foo bar > test.txt$ ex -c '$' -c '?bar' -c 'visual' test.txtAt this point the cursor is on line 2 instead of line 4, as expected. Using ex -c '?bar' -c 'visual' test.txt produces the same result, even though I'd expect it to find the last line when wrapping around (vim does).Using Vim 7.3.
How to find last matching line with ex?
ex