Anirudha Patil
Anirudha Patil

Reputation: 75

Goto definition like feature in custom (user-defined) language in notepad++

Is there any way (by means of plugins or settings) to create (by that I mean modifying, adding & deleting) custom tags in notepad++? By tags I mean, to jump to the definition of an instance used anywhere in project (some kind of like 'goto definition' function like we have in other popular languages like C, C++, C#). I searched for this topic but could not find satisfactory result.

My requirement: I have created a custom language in Notepad++ (by adding keywords, coloring patterns and other rules). Now I need the way to add custom tags for this language. How can I achieve this? With the help of tags I should be able to navigate to definition (just like goto definition in other popular languages) in the particular project (all files in project or at least opened files).

Upvotes: 4

Views: 1360

Answers (2)

Owen
Owen

Reputation: 209

I have just had to deal with essentially the same issue. I am using Notepad++ with a legacy codebase written in a custom markup language. Each file can contain cross references to definitions in other files, so a way of jumping to the definition would be very useful.

It has not been easy to find a solution that meets all four requirements: a goto definiton feature that works across multiple files and for a custom language in Notepad++. I found this question while searching for a solution; the answer jussij provided is good but it does not really provide a complete solution.

I ended up using the SourceCookifier plugin with a custom language definition. There is not a huge amount of guidance online about how to use it, but once installed you can use it to manually create a language definition using regex rules.

SourceCookifier will work for your language if you can configure the following:

  • A set of file extensions used by the language
  • A set of tag types (i.e. a function, class, variable)
  • A set of POSIX Basic Regular Expressions for locating each tag type, see this post

Once a language has been defined, you can highlight any instance of a found tag and use the shortcut Ctrl+Shift+Enter to jump to the definition of that tag. This can work across a whole codebase of files if you provide it with a list of files to inspect, it calls this a 'session'. All you need to do is drag and drop your codebase folder into the SourceCookifier sidebar window. The codebase I was working with is very large, so I am only using basic functionality, see this post for a good explination of that. The goto definition shortcut can also be added to a right-click context menu, see this post.

Upvotes: 1

jussij
jussij

Reputation: 10560

Now I need the way to add custom tags for this language. How can I achieve this?

If you're using Exuberant Ctags you can configure a new language definition using just a handful of regular expressions.

For example this link shows how to configure ctags for the Clipper language using this regexp approach:

Upvotes: 3

Related Questions