Tuesday, September 22, 2026

Re: No error with ]s when nowrapscan?

Hi Tim,

On Tue, 22 Sept 2026 at 03:25, Tim Chase <vim@tim.thechases.com> wrote:
Playing with something recently, I discovered that ]s doesn't seem to
throw any sort of error when wrapscan is off and it hits the end of the
file.

To demonstrate with the following setup (where {one,two,three}.txt are
some files with a couple misspelled words scattered throughout each)

  $ vim one.txt two.txt three.txt
  :set hidden nowrapscan

I then repeatedly issued

  :try | exec 'norm ]s' | catch | n | endtry

(using @: then subsequently @@ makes this easy) which worked for finding
all the misspelled words in the *first* file, but after finding the
last one in that file, the ]s *should* fail because there is no "next"
bad-spelling in the current file and wrapscan is off.  So it seems like
the ]s *should* have thrown an exception, get caught, and then go to
the :next file instead where the process can repeat.  But it seems to
silently swallow the "no more bad spellings in the current file" without
letting me catch the condition.

AFAICT there's no

  :spellnext

type ex command or spellnext() function corresponding to ]s that might
be more error-cooperative.

Is there a better way to go about this? 

You could leverage temporary use of `:set debug=beep`.

Regards,
Doug 

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/CAJ1uvoC%3DwuKB3u3kA4%3D4Hp1LHSoiK%3De-cz44ts79kyXeSt9R0g%40mail.gmail.com.

No comments: