Re: help with rexpr please
- On Tuesday, September 25, 2012 11:27:23 PM UTC-5, Patrick wrote:
> HiYes, it does. What did you try? It's \w by the way, not /w.
> This is my first post here.
> I am new to vim but making good progress through self study. I don't know how to represent a word though. I know there is a /w word character but it does not seem to do what I am trying to do.
> Lets say i have four words and I want to delete 1, 3 and 4.I assume the extra space in "delete_me 3" is unintentional.
> delete_me1 leave_me delete_me2 delete_me 3
> could anyone help me represent this?
Here's a lazy way:
^ is start-of-line
\w\+ is one or more word characters (in other words, the first word)
\s\+ is the whitespace separating the first and second word
\(\w\+\) is one or more word characters (the second word), captured in a group for later use
.* matches the rest of the line starting from the first non-word character after the 2nd word.
Replace with \1, which is the 1st captured group, here being the desired 2nd word.
Here's a more exact method if the above is too liberal and matches things you don't want it to. Consult the help for an explanation:
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