Sublime Forum

Bibtex and others, "Select expand to brackets" fails

#1

If you try to expand to the inner brackets, those which enclose the text you are in, it totally fails, selecting the whole block of the @article or whatever entry you are in. Expand to brackets is one of the nicest features of ST and should be smarter. It, for example, should select string contents too, considering “brackets” the “quotes”, and so.

3 Likes

#2

I entirely agree and vote for support of ’ ', " " and even user-defined pair of quotes such as « » in addition to brackets ( ), square brackets [ ] and braces { }.
For example, I frequently need to select text within a pair of quotes (only the text, without the quote characters around it).
As an author of XBrackets plugin for AkelPad, I also miss the feature of “GoToNearestBracket” that jumps to the nearest bracket or quote character when the caret is placed somewhere between a pair of brackets or quotes.
You may also consider the amount of manual options related to dealing with brackets/quotes :slight_smile:
Finally, you may consider how “SelToNearestBrackets” works in XBrackets:

  • first it selects the text between brackets/quotes, without the surrounding brackets/quotes;
  • then (if called again) it adds the surrounding brackets/quotes to the selection;
  • then (if called again) it selects the text between outer brackets/quotes that surround the already selected text, without these surrounding brackets/quotes;
  • then (if called again) it adds the surrounding brackets/quotes to the selection;
  • etc.
0 Likes

#3

Wow! That’s a challenge! Isn’t it there anything related on ST plugins? I have only a few personal plugins. The most proud I’m of was not for ST, but for its grandparent, Alpha for MacOS: search prev/next selected text

Has anyone tried your challenge?

0 Likes

#4

Reasons for expand_selection to brackets might fail due to chosen scope names in various syntax definitions, which the functionality seems to rely on - when not running on plain text. It normally works pretty well.

An attempt to fix it for BibTeX was made at https://github.com/sublimehq/Packages/issues/3952.

It seems to work In rewritten LaTeX on master as well, as long as no comments are involved.


Jumping to brackets is supported via ctrl+m key binding.

Expand to quotation marks works via expand_selection with smart argument passed (e.g.: ctrl+shift+a). It does not cover special quotes though.

Missing functionality could be provided by plugins. I am not aware of one doing so, however.

1 Like

#5

@deathaxe, thank you for taking the time to do this!

Unfortunately, it is not working for me. As I click Expand Selection to Brackets, it does not expand to the curly brackets of the entry, but the brackets of the entire article. The new syntax is loading, as I was seeing 4 different scopes with the cursor inside curly brackets of an entry, and now I see 6.

Below I put the code I am using:

@article{AbernethyKuangQin2015,
	title={The influence of CEO power on compensation contract design},
	author={Abernethy, Margaret A and Kuang, Yu Flora and Qin, Bo},
	journal={The Accounting Review},
	volume={90},
	number={4},
	pages={1265--1306},
	year={2015},
	publisher={American Accounting Association}
}
0 Likes

#6

The values are currently scoped string.quoted.other with curly braces treated as quotation marks. Thus they are affected by “Expand Selection” (ctrl+shift+a), only.

0 Likes

#7

Well, thanks. "super+shift+a" works better but not well. It starts correctly selecting the in-nest context, “quoted” or {curlybraced}, fine!, but then, it expands the selection to the origin of the line, funny, and if you want the wider scope that contains the whole entry… it fails and selects the whole document, if a bit confuse and makes you don’t trust it

0 Likes

#8

That’s not exactly what I see. With BibTex syntax from https://github.com/sublimehq/Packages/pull/3953, ST4173 on Win11 it seems to work - at least for the given sample article.

Animation

It fails (stops at line boundaries) however when starting with caret located in a key (e.g.: volume=):

Animation

As scopes don’t appear abnormal, I can’t provide any solution to that by a syntax definition patch.

Maybe a detailed issue report with examples and steps to reproduce would help sublimehq devs to narrow the root cause of it, down.

see: https://github.com/sublimehq/sublime_text/issues

0 Likes