Re: [gedit-list] Tab meaning



Peter Waller wrote:
> Dear List,
>
> My colleagues unfortunately all use emacs, with settings such that
> their C++ indentation is two spaces, except when it is four
> indentations wide, when it becomes a tab.
>
> In other words, a tab is 8 spaces wide, but the indentation is 2
> spaces. I don't care about inserting tabs into the file, so I'm happy
> to set my indentation width to 2, but if I do this, then the existing
> code is incorrectly aligned.
>
> Is there any way to get this functionality with gedit? If I have to
> write my own plugin I'm happy to do so, if someone can point me in the
> right direction.
I think what you want is supported by gtksourceview (which is what we
use as the editing widget), it's just not exposed in the configuration.
gtksourceview has the following properties:

tab-width: the width (number of spaces) each tab should be rendered
indent-width: the width (in number of spaces) of one indentation step
(when you press <tab> or <shift><tab>)
insert-spaces-instead-of-tabs: insert spaces instead of tabs when
pressing <tab>

The idea, I think, is then to use the following settings:

tab-width: 4
indent-width: 2
insert-spaces-instead-of-tabs: True

See the gtksourceview API documentation for more information on these
properties. In gedit, you can very easily try out different settings
using the Python Console plugin. In the bottom pane of this plugin, type:

doc = window.get_active_document()
doc.set_insert_spaces_instead_of_tabs(True)
doc.set_tab_width(4)
doc.set_indent_width(2)



>
> Thanks,
>
> - Peter
> ------------------------------------------------------------------------
>
> _______________________________________________
> gedit-list mailing list
> gedit-list gnome org
> http://mail.gnome.org/mailman/listinfo/gedit-list
>   



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]