I'm using vim with the tagbar, jsctags and taglist-plus plugins. They all seem to work correctly, but I cannot jump to a function/variable declaration. I tried ctrl+] but it doesn't work. Is it possible to setup vim so that you can jump to a function or variable declaration?
To go to definition, instead of Ctrl + ] , do Ctrl + \ + g .
If your cursor is on the line with the function name, try d } . It will delete everything to the next block (i.e. your function body). Within the function body itself, d a p will delete the 'paragraph'. You can delete a curly brace block with d a } .
TagBar and TagList don't generate the actual tags
file used by Vim to jump to definitions.
If you want this ability to jump you have to generate this file manually from the terminal:
$ ctags -R .
if you use ctags
or:
$ jsctags .
if you use jsctags
or from Vim itself.
Without needing jsctags, I have the following in my ~/.ctags for handling JavaScript correctly:
--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
generates the appropriate tagfile to match JavaScript function (and variable and object) definitions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With