Find patterns in Gvim

16 views
Skip to first unread message

Julius Hamilton

unread,
Sep 9, 2021, 8:24:34 AM9/9/21
to v...@vim.org
Hey,

From trying it myself, it seems that the "find" menu option in Gvim does not allow entering patterns or regular expressions, such as a period to represent any character, or "\n" to represent a newline, but only literal, explicit text matching.

I was curious why this is and if there is any GUI / menu way to search for regular expression patterns or if you must use the Vim text-based command "/" for this.

Thank you very much,
Julius

Christian Brabandt

unread,
Sep 9, 2021, 8:37:10 AM9/9/21
to v...@vim.org
Yes, I think the :promptfind and :promptreplace commands do a literal
search and replace only. If you want to use regexes, just use the `/`
(for finding) or `:%s` (for replacing) command.

Best,
Christian
--
Frau Weber liest in einem Gedichtband. Auf einmal ruft sie: "Du, Theo,
stell Dir vor, hier hat doch tatsächlich ein gewisser Rilke das
Gedicht abgeschrieben, das Du vor dreißig Jahren eigens für mich
geschrieben hast!"

Bram Moolenaar

unread,
Sep 9, 2021, 1:42:51 PM9/9/21
to vim...@googlegroups.com, Julius Hamilton, v...@vim.org
This was an intentional choice. The idea is that the menu would be used
by beginners, who don't know the keyboard commands yet. These users
would also not know what characters need to be escaped in a pattern.

As Christian mentioned, once you know Vim a bit you would just use
"/pattern" and ":s/from/to".

--
hundred-and-one symptoms of being an internet addict:
16. You step out of your room and realize that your parents have moved and
you don't have a clue when it happened.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages