如何在vim中使用ctag时显示相对路径

时间:2013-12-04 15:14:20

标签: vim ctags

我有一个带有“make tags cscope”的Linux内核生成的标签/ cscope文件。

现在,当我这样做时:

vim -t tcp_ack

它显示:

Cscope tag: tcp_ack
   #   line  filename / context / line
   1    678  /home/christoph/workspace/linux/mptcp/drivers/net/ethernet/neterion/s2io.h <<tcp_ack>>
             __be32 tcp_ack;
   2     56  /home/christoph/workspace/linux/mptcp/include/linux/inet_lro.h <<tcp_ack>>
             __be32 tcp_ack;
   3   3292  /home/christoph/workspace/linux/mptcp/net/ipv4/tcp_input.c <<tcp_ack>>
             static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
Type number and <Enter> (empty cancels): 

如您所见,它显示文件的完整路径。但是,我希望它只显示文件的相对路径。类似的东西:

Cscope tag: tcp_ack
   #   line  filename / context / line
   1    678  drivers/net/ethernet/neterion/s2io.h <<tcp_ack>>
             __be32 tcp_ack;
   2     56  include/linux/inet_lro.h <<tcp_ack>>
             __be32 tcp_ack;
   3   3292  net/ipv4/tcp_input.c <<tcp_ack>>
             static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
Type number and <Enter> (empty cancels): 

我怎样才能做到这一点?

感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

在Vim显示索引器记录的路径时,这不是真正的显示问题。

如果你想要tags文件中的相对文件名(因此在Vim的列表中),你必须通过传递--tag-relative=yes选项明确告诉ctags这样做。

据我所知,cscope默认使用相对路径。