ctrl-] is not working for tcl code navigation
Asked Answered
J

5

5

I am new to Tcl/Tk, I am using Vim to code and browsing. The syntax highlighting for Tcl/Tk is working fine. The jump into the function using Ctrl] doesnt work it gives me an message saying that "cstag: tag not found". I have installed ctags and generated tags using "ctags -R *.tcl". I have extensively used namespaces in Tcl/Tk code. The tags generated in tags file is something like this "namespace1::function1".

How do i get Ctrl] (and CtrlT for popping from stack) working in Vim?

The function to jump could be in either of the 2 formats shown below

  1. function1
  2. namespace1::function1
Jezebel answered 18/6, 2012 at 7:34 Comment(1)
Beware that ctags -R *.tcl would generate tags only for the files in the current directory, that unless your subdirs also have extension .tcl. Try ctags -R . instead.Number
J
3

Found a work around for my problem:

The tags file that generated contained tags in the format namespace::function.

I just removed namespace:: from generated tags file.
Now Ctrl + ] works!!!

Jezebel answered 3/7, 2012 at 2:28 Comment(0)
C
3

Try:

:set isk+=:

Seems like ":" doesn't get recognized as a codeword by default.

To make this work every time, add the line to your '~/.vimrc'.

Source: http://vim.1045645.n5.nabble.com/How-to-have-vim-recognize-in-cursor-for-tcl-namespaces-tp1163540p1163541.html

Checkerwork answered 21/10, 2013 at 11:14 Comment(1)
That's actually the proper answer to the question. Why has it got down voted?Brussels
L
2

Vim said he can't find the tags you generated.

Add set tags=./tags,tags; in your .vimrc and try again.

Lima answered 18/6, 2012 at 7:39 Comment(3)
xdazz, thanks for your reply but its not working...I am guessing that the map for ctrl-] is not getting set properly meaning if it gets set to namespace1::function1 then it should work. However I am able to navigate to that function by using :ta namespace1::function1...Jezebel
Are you opening Vim from the same directory that contains the tags file? If you generated the tags file in the Tcl/Tk directory but started Vim in your home directory or something, it won't read it unless you set the tags parameter as shown in this answer, but adding the Tcl/Tk directory to the list.Berdichev
@Derek: I am opening Vim from the same director which contains the tags file.Jezebel
R
1

Your .vimrc should have the following line

set tags=tags;/

Paste it, save, restart vim and you're golden.

Rife answered 23/8, 2017 at 21:9 Comment(0)
A
0

What keyboard layout are you using? I'm not familiar with your particular problem, but I've had problems with Ctrl+] on a Swedish keyboard when navigating the help pages.

There, Ctrl+] doesn't work for me (probably since ] is typed with Altgr+9). However, Ctrl+ 'key to the left of Enter' works (which is where ] is located on an English keyboard layout).

I can add that for my problem with the help pages I first tried to map Ctrl+] to another combination, but this still didn't work (not sure why). So if you are having the same problem, remapping might not solve the problem.

Argive answered 4/7, 2012 at 11:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.