Vim :: Creating Syntax Files
There is a syntactical feature I would like to see in Vim, and so I thought to write myself a syntax file for my needs, but I am having trouble finding the exact type of syntax highlighting I want to incorporate'emulate.
Currently in Vim, from the terminal instead of say gvim, when I place my cursor over a parenthesis or brace, the corresponding brace or parenthesis will highlight, or block its character. In my case, instead of a single character they will be full words specified within the syntax file.
I want to do something similar. For example if my document has three words:
I want the syntax file to tell Vim that when I have my cursor over the word Element1 or Element2 that Group will become highlighted. In the same, to have the cursor over Group will cause both Element1 and Element2 to highlight.
Examples of this sort of implementation would be greatly appreciated.
I have looked here but understanding still eludes me:
::I would also be happy with creating some sort of command input, where I type in the group name and the elements highlight. Like a very specific search function that searches for only and all instances that are contained within the group named.
Hm... I don't quite see how your system will work. To save space, let's say Group=$ Element1=( Element2=). So with "$()" (your example), you would expect both ( and ) to highlight when hovered over $, but only $ to highlight when hovered over either parenthesis? How do you decide which elements match up? With brackets, the rule is simple. You start counting from the first bracket until the number of close brackets = the number of open brackets, then the next close bracket is the matching bracket. With your example, how do you know which sets form a group? Is there something specific you're trying to implement syntax highlighting for? If you had something more complicated than just "$()", like "$($)()$$())($", which ones would/should vim be highlighting as a group?
You have the concept correct, but instead of single characters I want full words.
I want to create groups and elements which will be static and listed within the syntax file.
So if my syntax file says the group will be 'Editors', and also in the syntax file it says that within the group 'Editors' there are two elements 'Vim' 'gVim', then whenever I cursor over the word Editors, then all instances of Vim or gVim found within the file highlight.
A way to show all elements of a group effortlessly.
Also, if one was to cursor over the elements Vim or gVim then the word Editors would highlight.
The similarity to the paranthesis or braces, was not its ability to find the next or preceding, but rather the cursor over then highlighting rather than instant highlighting.
I would also be happy with creating some sort of command input, where I type in the group name and the elements highlight. Like a very specific search function that searches for only and all instances that are contained within the group named.
Hm, I haven't been able to find/think of anything... The best I could come up with is using a version of vim with search highlighting and using a search like:
Thanks for thinking about it, and looking for some solutions... I am with you, this thing is elusive.
I wrote a script that eats up the file and spits out the necessary info, but I just thought it would be nice to have it as a built in feature.
The project is an intended learning tool. The script reads in the include information from a C program and then searches the program for the functions within the program that use this library, and opens the corresponding man page. That way if you are taking apart some open source to try to learn how it all works, this kind of gives you the initial knowledge to then use to try to understand its implementation.
The Vim idea was when you had your cursor over the include statement the functions would highlight, and if you put your cursor over an unrecognised function it would highlight what library to investigate to learn what it is and does, and how to call it properly.
|All times are GMT -5. The time now is 09:07 AM.|