matching parentheses OR brackets

Asked by Chip Eastham

I wonder if gedit has the ability to match parentheses or brackets. On many editing tools in Windows the keystroke Ctrl-M will trigger a search for a matching parenthesis or bracket if the cursor is on or before a parenthesis or bracket, searching forward if the cursor is on a closing brace or backward if an opening brace. Some Unix legacy editing tools like vi have a similar feature using a different keystroke trigger.

I could find nothing in the gedit help files that addressed this question one way or the other. Ctrl-M doesn't do the job, and the vi strategy (uses '%') depends on having separate modes for "command" and "text entry" (where gedit is modeless in that respect, using the GUI/menu approach to "command" features).

I do see that one of the gedit plugins provides bracket completion, but that's not so useful when pre-existing files have to be edited.

regards, chip

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gedit Edit question
Assignee:
No assignee Edit question
Solved by:
David Mawdsley
Solved:
Last query:
Last reply:
Revision history for this message
Anzenketh (anzenketh) said :
#1

Might want to check the available plug-ins see if one fits your needs.

http://projects.gnome.org/gedit/plugins.html

Revision history for this message
Tom (tom6) said :
#2

Hi :)

I think that those pre-existing files can still make use of the add-on. You don't have to use the same text-editor on the same file. I sometimes find it quite useful to use a variety of different text-editors on a particular file as each text-editor has something unique that might be useful.

Gedit is not really meant to be a sophisticated text-editor, it's more along the lines of NotePad in Windows rather than SciTe. If you want a nice decent text-editor than try a quick search in Synaptic Package Manager
https://help.ubuntu.com/community/SynapticHowto

There are a LOT of different text-editors out there even restricting yourself to gtk or gnome ones.
http://www.linuxquestions.org
just ran a competition to find people's favourite one although their voting list was quite restricted.

Good luck and happy hunting
Regards from
Tom :)

Revision history for this message
Best David Mawdsley (dm-madmod) said :
#3

I use gedit 2.22.3 in the Ubuntu 8.04 environment to write scripts in Bash, Python, HTML and JavaScript. What I've found is that merely typing parentheses and within nested ones such as:

prinpaid = (ab*ir*math.pow(1+ir/1200,k-1))/(1200*(mp-1))

that when the cursor is near either a left or a right parenthesis, the corresponding opposite one is automatically highlighted in gray. So if my cursor is between the 'w' and the '(' in 'math.pow', then the parenthesis after the '1' in 'k-1' is highlighted automatically in gray.

I didn't notice this happening until about a month ago--years after first using gedit. (I guess I'm a slow learner sometimes.) This very subtle matching is probably what you're looking for. I find this highlighting very useful.

-Dave

Revision history for this message
Chip Eastham (hardmath) said :
#4

You're right, Dave. The bracket "matching" is done by highlighting, and this is an option controlled by a checkbox on the View tab of the Preferences dialog in gedit. Once I turn it on, I was happy with the builtin feature.

Thanks to you and Tom for the quick replies.

regards, chip

Revision history for this message
Chip Eastham (hardmath) said :
#5

Thanks David Mawdsley, that solved my question.

Revision history for this message
Tom (tom6) said :
#6

Congrats, nicely fixed :))

It seems that gedit is a lot more sophisticated than i thought and perhaps has new functionality being added over the years too :) It's all good :)

Regards from
Tom