Friday, July 29, 2011

Re: question about 'isfname'

On 2011-07-29, sc wrote:
> list--
>
> i like to grep and pipe the results into an unnamed hidden vim
> buffer so when i see a module i want to edit i can hit F4 on
> it
>
> i have F4 defined as
>
> map <F4> :call OpenWhat()<CR>
> function! OpenWhat()
> let testme = expand("<cfile>")
> if isdirectory(testme)
> call CdMaik()
> else
> e <cfile>
> endif
> endfunction
>
> the relevant portion being the edit of <cfile>
>
> a typical chunk of grep output might look like the following:
>
> hl:open(PRS, ".prime_run_start");
> hl2:open(PRS, ".prime_run_start");
> inst:echo "restoreprs restores .prime_run_start from save_prs"
> inst:echo "saveprs saves .prime_run_start to save_prs"
> nmt:open(PRS, ".prime_run_start");
>
> when it first comes up, F4 performs fine and i am able to edit
> for example 'hl' because the default value for 'isfname' does
> not include ':'
>
> however, when 'hl' is a perl module, 'isfname' gets redefined
> by $RUNTIME/ftplugin/perl.vim so when i quit or bp back to the
> unnamed buffer with the grep output my F4 no longer works --
> perl.vim adds ':' to 'isfname' and now it would try to open
> 'hl:open', creating a new file by that name
>
> according to the help isfname is a global option so forcing
> perl.vim to perform a setlocal would have no effect
>
> has anyone else run into this and if so, how did you deal with
> it?

If the file name is always to the left of the ':', you could change

let testme = expand("<cfile>")

to

let testme = substitute(expand("<cfile>"), ':.*', '', '')

Regards,
Gary

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