How to get to the definition of a javascript function in vim?

I use vim with plugins tagbar, jsctags and taglist-plus. All of them work correctly, but I can not proceed to the declaration of the function / variable. I tried ctrl +], but it does not work. Is it possible to set vim so that you can move on to declaring a function or variable?

+8
javascript vim plugins
source share
2 answers

Without using jsctags, I have the following in ~ ~ .ctags to correctly handle JavaScript:

--regex-JavaScript=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*new[ \t]+Object\(/\1/o,object/ --regex-JavaScript=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/o,object/ --regex-JavaScript=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/f,function/ --regex-JavaScript=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*\([^\]\)]*\)/\1/f,function/ --regex-JavaScript=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*new[ \t]+Array\(/\1/a,array/ --regex-JavaScript=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/a,array/ --regex-JavaScript=/([^= ]+)[ \t]*=[ \t]*[^""]'[^'']*/\1/s,string/ --regex-JavaScript=/([^= ]+)[ \t]*=[ \t]*[^'']"[^""]*/\1/s,string/ 

Using the above, a simple ctags -R creates an appropriate tag file to match the definitions of a JavaScript function (and variables and objects).

+6
source share

TagBar and TagList do not generate the actual tags file used by Vim to navigate to the definitions.

If you want this ability to jump, you need to generate this file manually from the terminal:

 $ ctags -R . 

if you use ctags or:

 $ jsctags . 

if you use jsctags or from vim itself.

+3
source share

All Articles