求解,用ctags然后enc和tags文件的编码(或者是cpp文件的编码)不一致时,^[跳不到正确位置

Vim、Emacs配置和使用
回复
Lyd
帖子: 16
注册时间: 2011-03-12 11:58

求解,用ctags然后enc和tags文件的编码(或者是cpp文件的编码)不一致时,^[跳不到正确位置

#1

帖子 Lyd » 2011-08-16 13:40

cpp文件里有中文。enc=utf-8但fenc是cp936的时候,^[只能跳转到对应的文件的第一行,然后提示:
E434:找不到 tag 模式
set enc=cp936之后就跳转正常了,又不能简单地set enc=cp936,毕竟网上很多代码都是utf8的,有啥其他解决方法么?
头像
fanhe
帖子: 2357
注册时间: 2007-03-24 23:45

Re: 求解,用ctags然后enc和tags文件的编码(或者是cpp文件的编码)不一致时,^[跳不到正确位置

#2

帖子 fanhe » 2011-08-16 13:58

我只用 cscope 跳转, 帮顶
Lyd
帖子: 16
注册时间: 2011-03-12 11:58

Re: 求解,用ctags然后enc和tags文件的编码(或者是cpp文件的编码)不一致时,^[跳不到正确位置

#4

帖子 Lyd » 2011-08-16 14:43

lilydjwg 写了:统一编码。
就是要enc和fenc一致?还是说要我用平时用统一的编码?
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: 求解,用ctags然后enc和tags文件的编码(或者是cpp文件的编码)不一致时,^[跳不到正确位置

#5

帖子 lilydjwg » 2011-08-16 15:01

Lyd 写了:
lilydjwg 写了:统一编码。
就是要enc和fenc一致?还是说要我用平时用统一的编码?
当然是后者。
Lyd
帖子: 16
注册时间: 2011-03-12 11:58

Re: 求解,用ctags然后enc和tags文件的编码(或者是cpp文件的编码)不一致时,^[跳不到正确位置

#6

帖子 Lyd » 2011-08-16 15:05

lilydjwg 写了:
Lyd 写了:
lilydjwg 写了:统一编码。
就是要enc和fenc一致?还是说要我用平时用统一的编码?
当然是后者。
got it...
kmindg
帖子: 1
注册时间: 2011-10-09 16:20

Re: 求解,用ctags然后enc和tags文件的编码(或者是cpp文件的编码)不一致时,^[跳不到正确位置

#7

帖子 kmindg » 2011-10-09 16:28

我也碰到这个问题了 摸索了一下 发现可用用ctags 的--excmd=number参数解决这个问题,当然也是有利有弊的,比如减小tags文件大小,但是修改文件很可能造成跳转偏移几行,需要重新生成tags文件。

详细见ctags man:
--excmd=type
Determines the type of EX command used to locate tags in the source file. [Ignored in etags mode]
The valid values for type (either the entire word or the first letter is accepted) are:

number
Use only line numbers in the tag file for locating tags. This has four advantages:
1. Significantly reduces the size of the resulting tag file.
2. Eliminates failures to find tags because the line defining the tag has changed, causing the pattern match to fail (note that some editors, such as vim, are able to recover in many such instances).
3. Eliminates finding identical matching, but incorrect, source lines (see BUGS, below).
4. Retains separate entries in the tag file for lines which are identical in content. In pattern mode, duplicate entries are dropped because the search patterns they generate are identical, making the duplicate entries useless.

However, this option has one significant drawback: changes to the source files can cause the line numbers recorded in the tag file to no longer correspond to the lines in the source file, causing jumps to some tags to miss the target definition by one or more lines. Basically, this option is best used when the source code to which it is applied is not subject to change. Selecting this option type causes the following options to be ignored: -BF.

pattern
Use only search patterns for all tags, rather than the line numbers usually used for macro definitions. This has the advantage of not referencing obsolete line numbers when lines have been added or removed since the tag file was generated.

mixed

In this mode, patterns are generally used with a few exceptions. For C, line numbers are used for macro definition tags. This was the default format generated by the original ctags and is, therefore, retained as the default for this option. For Fortran, line numbers are used for common blocks because their corresponding source lines are generally identical, making pattern searches useless for finding all matches.
回复