Friday, November 25, 2011

Re: Open a file whose name is selected after a search pattern in the current line

On 11/25/11 17:36, Albin Olsson wrote:
> On Fri, Nov 25, 2011 at 11:31 PM, Tim Chase<vim@tim.thechases.com> wrote:
>> On 11/25/11 09:33, Fabio Spelta wrote:
>>>
>>> Suppose I have a file that reads like
>>>
>>> sometxt1 somemoretxt2 abc.TEXTIWANT3.cde
>>> sometxt2 somemoretxt5 fgh.TEXTIWANT6.ijk
>>>
>>> and so on.
>>>
>>> I want to extract the TEXTIWANTX part and open a file named
>>> TEXTIWANTX.txt by executing a command (hitting a key, whatever) when I
>>> am on a line formatted like that.
>
> Here is my solution:
> nmap<F1> 0f.lyt.:e<c-r>0.txt<cr>'

Yeah, there were a couple shorter specific-case solutions that I
came up with, but the one I gave should be able to handle the
generic case of "search for something and then extract it (plus
any subsequent digits), tack on '.txt' and open the result as a file"

-tim


--
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

No comments: