Monday, August 17, 2015

Search in selection - difference in behaviour between ':s' and '/' (or ':/')

This is based on: http://vim.wikia.com/wiki/Search_and_replace_in_a_visual_selection
and was supposed not to be about \%V, which just works.

Lets suppose that one does the following:
- V, select a few lines
- ':', followed by either 's' or '/': ':s' or ':/'
- type a search pattern [and a replacement text for 's']
If that's the case, then typing ':s/<pattern>/<replacement>' will replace text _within selection_ and typing ':/<pattern>' will search the text within _the entire file_. I don't understand why those two behave differently.
1. Could you describe why there is a difference in behaviour between the above.
2. Is '/' an Ex command?
3. Is ':/' an Ex command?
4. What does ':/' really mean? (is it an Ex command that redirects to the Search 'mode'?)
5. Why doesn't ":'<,'>/<pattern>" work 'as expected' - search for <pattern> within selection (selection specified by the special 'selection' range)?
6. What would it mean if after selecting a few lines, one would just type '/' (instead of ':/') (~so that the ranges '< and '> do not appear) - is the selection ignored entirely in this case and a search on a file is just performed?

Regards.

--
--
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.
For more options, visit https://groups.google.com/d/optout.

No comments: