ctags5.8 supports Golang languages with custom extensions

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Ctags tool is used to traverse the source code files generated tags files, these tags files can be used by the editor or other tools to quickly find the location of the source code symbols (Tag/symbol), such as variable name, function name and so on. For example, tags files are the basis for taglist and omnicppcomplete work.

Its installation and use of local do not do too much to repeat.

Now let's talk about how to configure your own ctags to support Golang

Problem Description:

If you find that your ctags cannot support Golang, check the ctags version Ctags first:

Ctags--versionexuberant ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert compiled:sep  , 03:28:50  Address es: <dhiebert@users.sourceforge.net>, Http://ctags.sourceforge.net  Optional compiled features: +wildcards , +regex

Found to be 5.8, the current official note ctags5.8 stable version is not supported by Golang.

You can view its supported languages from the command:

Ctags--list-languagesantasmaspawkbasicbetacc++c# Coboldosbatcheiffelerlangflexfortranhtmljavajavascriptlispluamakematlabocamlpascalperlphppythonrexxrubyschemeshslangsmlsq Ltcltexveraverilogvhdlvimyacc

Found none of the Golang.


Add the following code in the ~/.ctags file (no new)

--langdef=go--langmap=go:.go--regex-go=/func ([\t]+\ ([^)]+\))? [\t]+ ([a-za-z0-9_]+)/\2/d,func/--regex-go=/var[\t]+ ([a-za-z_][a-za-z0-9_]+]/\1/d,var/--regex-go=/type[\t]+ ([ a-za-z_][a-za-z0-9_]+)/\1/d,type/

And then go through Ctags--list-languages To see the discovery can support Golang language, after the ctags to Golang for a pleasant jump and bounce.

The supported file types and suffixes found in ctags can be viewed by following several commands:


More ctags usage can be viewed through ctags--help.

Reference Link: http://stackoverflow.com/questions/8204367/ctag-database-for-go

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.