Dear all,
First of all, thank you to the developers for the hard work they put on Textmate! I have been using it since 2009, when you had to pay for it, and since then I have convinced about 5 people to use it.
Say that I am editing a C/C++ file, with plenty of nested loops and "if" conditions. Is there a command to show an outline of these scopes and at which level the caret is in such hierarchy? For example, if the caret is inside this nested loop:
void func (int N) {
if (N<10) { for (int i=0, i<N, i++) { for (int j=0, j<N, j++) { for (int k=0, k<N, k++) { printf ("%g\n", i*j*k); <caret is here> } } } }
} // end of func
I know that I can find the function name in the status bar, or by pressing cmd+shift+t, but I am not aware about a command that would tell me that I am in the *k-j-i* loop of the *if(N<10)* branch. This would be very handy as some codes make heavy use of nested loops.
Thank you for your attention, Guido
-- View this message in context: http://textmate.1073791.n5.nabble.com/Show-current-scope-block-but-not-Textm... Sent from the textmate users mailing list archive at Nabble.com.
Hi Guido,
On 06 Jun 2014, at 13:32, coccoinomane coccoinomane@gmail.com wrote:
Say that I am editing a C/C++ file, with plenty of nested loops and "if" conditions. Is there a command to show an outline of these scopes and at which level the caret is in such hierarchy? For example, if the caret is inside this nested loop:
I’m using "Edit > Select > Current Scope" or "Edit > Select > Enclosing Typing Pairs” to come up with a selection. You can also execute them more than once to go one level up.
Cheers, Hans
Thank you Hans for your prompt reply! The method you suggest does help, but I was looking for something slightly different.
I would like to have information on the current scope to be printed, for example, as a tooltip. Again, by "scope" here I mean in the programming sense (if block, for loop, etc.), not the Textmate one (source.c, meta.function.c), even though probably the former can be extracted from the latter. I would find this feature very helpful to navigate my way into complex code.
Cheers, Guido
-- View this message in context: http://textmate.1073791.n5.nabble.com/Show-current-scope-block-but-not-Textm... Sent from the textmate users mailing list archive at Nabble.com.
On 6 Jun 2014, at 21:45, coccoinomane wrote:
I would like to have information on the current scope to be printed, for example, as a tooltip. Again, by "scope" here I mean in the programming sense […]
You can write a custom command that takes “document” as input and shows its output in a tool tip.
This command can use the TM_LINE_NUMBER environment variable to figure out what line the caret is at, and then what “scope” you’re in.