How to implement a custom tag in VIM using CTRL-]?

If: VIM uses h, it will automatically follow the links | via CTRL + ] , opening new help topics and maintaining a list of tags ( CTRL + T will return to the navigation history). How to implement this behavior in my own format? For example, I want CTRL + ] in the text inside {} to open a file called something.txt and CTRL + T to return. How to implement this?

+2
source share
1 answer

All this is done using tags. In essence, vim files are simple text files, but they are supported by a file in the same directory as "tags". This entire file contains entries that look like this:

'bg' options.txt /*'bg'* 'bh' options.txt /*'bh'* 'bin' options.txt /*'bin'* 'binary' options.txt /*'binary'* 'biosk' options.txt /*'biosk'* 'bioskey' options.txt /*'bioskey'* 

Each line is a tag entry, divided into three fields: the tag identifier, the file in which the tag is located, and the ex command to find this tag: any ex command works; as you can see from the above example, vim help files just use the search command: '/'.

You can either write the tag file manually, or use a program such as Exuberent ctags to automatically create the file. A tag file is usually read from the same directory as the file you are editing, but you can change it in Vim by setting the tag parameter.

More in vim if you type " :help tags "

+5
source

All Articles