开发者

Vim doesn't expand <cfile>

开发者 https://www.devze.com 2023-01-02 09:26 出处:网络
I\'m having a problem when try开发者_如何学JAVAing to make vim expand the file name under cursor. For example:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消