Vim 在文档目录外编辑帮助文件会导致在中复制时标记不起作用

Vim 在文档目录外编辑帮助文件会导致在中复制时标记不起作用,vim,tags,Vim,Tags,我已经在$VIM\vimfiles\doc下创建了一个帮助文件。在几乎删除它之后,我想在别处编辑它,然后将它复制到doc目录,然后重新生成标记 标记已生成,我可以在标记文件中看到它们,但是我复制的文件,唯一的名称,当我这样做时:h sfcontents for eg,然后ctrl-]在标记上,我得到错误“e426 tag not found” 如果我编辑$VIM\vimfiles\doc目录中的文件,然后运行:Helptags或:Helptags$VIM\vimfiles\doc,则标记跳转会起

我已经在$VIM\vimfiles\doc下创建了一个帮助文件。在几乎删除它之后,我想在别处编辑它,然后将它复制到doc目录,然后重新生成标记

标记已生成,我可以在标记文件中看到它们,但是我复制的文件,唯一的名称,当我这样做时:h sfcontents for eg,然后ctrl-]在标记上,我得到错误“e426 tag not found”

如果我编辑$VIM\vimfiles\doc目录中的文件,然后运行:Helptags或:Helptags$VIM\vimfiles\doc,则标记跳转会起作用

我无法附加文件,但帮助文件看起来像

vim: filetype=help foldmethod=indent foldclose=all modifiable noreadonly
Table of Contents *sfcontents* 
*sfsearch* - Search specific commands help 
|count-matches-of-pattern|
|match-specific-column|
...
==============================================================================
count-matches-of-pattern
*count-matches-of-pattern*
:%s/pattern//gn 
counts the number of the matches in a file eg count the number of spaces
not at the beginning of a line 
:%s/[^ ]\+//gn
==============================================================================
*match-specific-column*  
c=column l=line v=virtual column, ie ignore tabs and special chars
/\%5cx will match all occurrences of x at column 5.  
/\%>5vx will match all occurrences of x after character 5. If there is a
tab character between poition 1 and position 5 the /\%5>v. against the
following line with a tab at position 4 will return the number 4
123 45
/\%>4cx\%<7cx will match all occurrences of x after column 4 and before
column 7

Or use |YankMatchesToReg| eg YankMatchesToReg /\%265v./x which copies
column 265 to register x across the whole file 
==============================================================================
...
vim:tw=88:ts=4:ft=help:norl
vim:filetype=help foldmethod=indent foldclose=all modifiable noreadonly
目录*SF内容*
*sfsearch*-搜索特定命令帮助
|计算模式的匹配数|
|匹配特定列|
...
==============================================================================
计算模式的匹配数
*计算模式的匹配数*
:%s/pattern//gn
计算文件中的匹配数,例如计算空格数
不是在一行的开头
:%s/[^]\+//gn
==============================================================================
*匹配特定列*
c=列l=行v=虚拟列,即忽略制表符和特殊字符
/\%5cx将匹配第5列中所有出现的x。
/\%>5vx将匹配字符5之后出现的所有x。如果有
在/\%5>v点1和位置5之间的制表符。反对
在位置4处带有制表符的下一行将返回数字4
123 45
/\%>4cx\%IMO,担心“几乎删除”一个文件不是在另一个位置编辑和来回复制的适当理由。事实上,您现在已经引入了另一种风险,即通过错误的复制命令意外丢失文件内容

相反,使用适当的版本控制(Git、Mercurial等),或者,如果太重,可以尝试my,一个纯Vimscript实现。有了它,您甚至可以备份到其他目录


这就是说,如果将帮助文件复制到正确的位置后运行
:helptags$VIM\vimfiles\doc
,则标记跳转应该可以在复制模式下工作。

直接从VIM的帮助文件(:h编写本地帮助):

Short:文件中的第一个字符缺少
*sfsearch.txt*


Vim不会添加到
|本地添加|
,因此不会被搜索,假设您的标签文件生成正确。您可以通过打开
/doc
目录中的
标记
文件并在那里手动查找标记来验证这一点。在每个正确标记了帮助标签的
/doc
目录(
:helptags
)中应该有一个
标签
文件。

版本控制是列表中的下一个,但是我使用了一些东西作为备份/版本控制,但它没有正确访问Vimfiles目录的权限。谢谢你的确认,它应该像我想的那样工作。我会继续尝试。啊哈,这解释了为什么我从中复制的帮助文件也不起作用。
nmap <leader>c :sp C:\Progra~2\vim\vimfiles\doc\commands.txt<cr>
nmap <leader>co :call BackupCommands()<cr>

function! BackupCommands()
     exec "silent! !copy C:\\Progra~2\\Vim\\vimfiles\\doc\\commands.txt        
     C:\\Progra~2\\vimutils\\vimtips\\commands_back.txt"
     exec "helptags C:\\Progra~2\\Vim\\vimfiles\\doc\\"
endfunction
The first line is actually the only one for which the format matters.  It will
be extracted from the help file to be put in the "LOCAL ADDITIONS:" section of
help.txt |local-additions|.  The first "*" must be in the first column of the
first line.  After adding your help file do ":help" and check that the entries
line up nicely.