Vim doesn't expand <cfile>
I'm having a problem when try开发者_如何学JAVAing to make vim expand the file name under cursor. For example:
include("../path/file.php");
When the cursor is on file name and I type gf
the file.php is opened just fine. However, when I remap the gf
command in vimrc this way: map gf :tabnew <cfile><CR>
, then instead of opening the file in a new tab gf
just opens up an empty file.
Any idea what I am doing wrong?
It should be.
:nnoremap gf :exe 'tabnew '.expand('<cfile>')<cr>
If I have the following directory structure:
~
|- ./foo/
| `-- bar.php
`- ./baz/
`-- bang.php
..and in bang.php: <?php include('../foo/bar.php'); ?>
This mapping works fine for me: :nnoremap gf :tabe <cfile><cr>
. The file ~/foo/bar.php is opened in a separate tab.
精彩评论