GNOME Bugzilla – Bug 107044
RFE: add hooks for indentation of text
Last modified: 2016-08-07 14:50:39 UTC
I'd like my code to be automatically indented. For example, if I write: int main() { if(TRUE) printf("test\n"); return(1); } Gedit should automatically change it to: int main() { if(TRUE) printf("test\n"); return(1); } That would be even better if gedit could use the same indentation as Emacs so that you don't break other people's code when editing it (especially when working on CVS projects).
Changing product to gtksourceview, since gedit will use it as text widget.
I don't think this belongs in gtksourceview. Looks like a perfect candidate for a gedit plugin, and it should be implemented by default in glimmer. But it's too high level for the widget (to start with, it's language dependent). We do need to provide good hooks into the view/buffer to ease its implementation. Paolo, what do you think?
Created attachment 45366 [details] IRC conversation on auto indetation I'm attaching this IRC conversation I had with gustavo and tberman on Feb. 21, 2004 since I have just found it on my old PC and I don't want to lose it again. I think it contains a good proposal for implementing auto indetation in GtkSourceView.
We should provide API hooks from which gedit, MonoDevelop and anjuta can hookup their own indentation code that indents C, C#, Python etc. GtkSourceView should define a default indentation hook that binds TAB and SHIFT_TAB to indent a text block with the tab size.
*** Bug 132824 has been marked as a duplicate of this bug. ***
*** Bug 307048 has been marked as a duplicate of this bug. ***
*** Bug 301456 has been marked as a duplicate of this bug. ***
Now that gtksourceview is now getting folding ability (and therefore the ability to define what is a 'block') this could possibly be added to gedit based on that feature. If the previous line created a new block, indent; if it closed a block, dedent; if neither, keep indentation. a little more information on this could be added to the syntax for specifying the code folding for the extra information (should the end code block be dedented or only after etc...)
There's the Gemini Gedit Plugin: http://www.garyharan.com/index.php/2006/11/16/gemini-gedit-plugin-for-all-those-textmate-fans/ that does a kind of block indentation: If we type a curly bracket: { then a bracket } is automatically added, the cursor between them. By pressing <Return>, we have the cursor ready to type indented code: { Cursor }
That link seems to be broken. https://github.com/gmate/gmate/tree/master/plugins/gedit2/gemini is active (thanks jp on irc), but doesn't work with gedit 3.x as far as i can tell. Anything currently maintained? This makes dev work with gedit pretty much a non-starter here.
@Jeremy: gmate (and so gemini) is being ported to gedit 3. See the following report: "Make gmate compatible with gedit 3" https://github.com/gmate/gmate/issues/65
Bug #736727 has more activity, with some initial patches. *** This bug has been marked as a duplicate of bug 736727 ***