tag:blogger.com,1999:blog-28654195.post6264366087799295195..comments2023-07-07T03:20:20.650-07:00Comments on VI Improved Tips :: vimrc dissected: Regex to match the word under cursorIhar Filipauhttp://www.blogger.com/profile/05086565400407007423noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-28654195.post-77106236830845725922012-12-04T22:56:38.676-08:002012-12-04T22:56:38.676-08:00Ah I see makes sense now. I just thought that for ...Ah I see makes sense now. I just thought that for your example with <em></em> those options are perfectly valid and I would use them instead.<br /><br />P.S. Hate blogspot - they don't even provide an option for pre tags...<br /><br />Best, Nikola<br />Nikola Valentinov Petrovhttps://www.blogger.com/profile/14017819580026769822noreply@blogger.comtag:blogger.com,1999:blog-28654195.post-66728157071656058512012-12-02T11:52:01.636-08:002012-12-02T11:52:01.636-08:00Nikola, welcome to the Blogspot - worst blogger pl...Nikola, welcome to the Blogspot - worst blogger platform for the technical discussions! Gotta html-quote everything here.<br /><br />[ Oh, you updated your comment. ]<br /><br />The expand() can give you the current word - but what can you do about it but to look at it? '\%#' allows you to actually DO something with the word. And 100% guaranteed to be the word under cursor - not any other instance of the word on the same line.<br /><br />^R^W isn't particularly useful for similar reason: it is rather for the interactive use, it's hard to automate and in the end it is as unrealiable as the expand().<br /><br />Additionally, it is not limited to the word. Word-under-cursor is probably the most popular application, but the regex actually can be easily extended, for example, to include punctutation or word before/after. Or match only part of the word. And so on and so forth.Ihar Filipauhttps://www.blogger.com/profile/05086565400407007423noreply@blogger.comtag:blogger.com,1999:blog-28654195.post-13025455024207677302012-12-02T11:40:54.194-08:002012-12-02T11:40:54.194-08:00reason why you are not using
expand('<cwo...reason why you are not using<br /><br /><br />expand('<cword>>)<br /><br /><br />or even better<br /><br /><br /><C-R><C-W><br /><br />when doing the substitution?<br /><br />Best, NikolaNikola Valentinov Petrovhttps://www.blogger.com/profile/14017819580026769822noreply@blogger.comtag:blogger.com,1999:blog-28654195.post-51224955049229399182012-12-02T11:36:39.980-08:002012-12-02T11:36:39.980-08:00This comment has been removed by the author.Nikola Valentinov Petrovhttps://www.blogger.com/profile/14017819580026769822noreply@blogger.com