Sunday, February 21, 2010

Re: Open a new file if the file doesn't exist when using ctrl+W_ctrl+F?

On Sun, 21 Feb 2010, Peng Yu wrote:

> If I type ctrl+W_ctrl+F over a string and there is not a file whose
> name is the string, vim will show "E447: Can't file file '<the
> string>' in path". However, sometimes I do want to open a new file
> with the string with some short cut. Is there a way to do so?

Interesting. I should have figured there was a shortcut for this.
Earlier tonight I came up with this snippet to do just that:

:map <C-O> :exe "new ".expand("<cfile>")<CR>

to open the file name under the cursor on pressing ctrl+shift+o. It
works regardless of whether that file exists.

In my case, I could just be using ctrl+W_ctrl+F.

The snippet above doesn't search any 'paths' though, AFAIK.

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: