Hello,
I have a question about tab identation. Imagine that I have code like this:
[1] ->->->... code [2] ->->->... code
Where [n] is line number, "->" is tab and "." is space.
If I press tab of shift+tab at first line, I get desired identation, but also an artifact: spaces (".") are replaced with tab and code in case of one tab become like this:
[1] ->->->->-> code
I want to save my space identation and if I change Preferences -> Editor -> Identation -> "Tab key idents" to unchecked, I get my desired tab key function. But that is true only if I change one line at a time.
If I select more lines (for example, first and second) and press tab of shift+tab, spaces are still replaced with tabs.
I do remember that at least one type of identation (tab or shift+tab) saved my spacing, but I can't recall in which version of Geany it was. And as I have clean (default) geany installation now, it may be due to configuration issue.
So my question is: how and if I can configure Geany to support my desired identation (save spaces) with tab/shift+tab.
Thanks in advance.
Andris Raugulis schrieb:
I want to save my space identation and if I change Preferences -> Editor -> Identation -> "Tab key idents" to unchecked, I get my desired tab key function. But that is true only if I change one line at a time.
If I select more lines (for example, first and second) and press tab of shift+tab, spaces are still replaced with tabs.
I do remember that at least one type of identation (tab or shift+tab) saved my spacing, but I can't recall in which version of Geany it was. And as I have clean (default) geany installation now, it may be due to configuration issue.
I can't remember such a feature. Leading spaces and tabs are generally indentation. And pressing shift+tab removes it. If you re-add it, it only adds the indention type you've configured.
Besides, I find it weird to even want such a mixed indentation. Why not use tabs or spaces consistently?
Best regards.
I can't remember such a feature. Leading spaces and tabs are generally indentation. And pressing shift+tab removes it. If you re-add it, it only adds the indention type you've configured.
As I mentioned, unchecking "Tab key idents", I get desired results, so, in my opinion, it should be possible for multi-lines, also.
And Now I think I remember that shift+tab was the one that used to work for multiple-lines. Anyway, one way or other (tab or shift+tab), it used to work. I'm pretty sure. Or my memory is broken.
Anyway, if I can't do this by configuration, how can I achieve my desired results? Snippet, plugin, local patch-branch?
Besides, I find it weird to even want such a mixed indentation. Why not use tabs or spaces consistently?
It's not pure identation. It's ident + align. And to answer your question - to make code readable. Consider this code (php example):
->->$sSQL = 'SELECT `column1` ' . ->->........' FROM `table` ' . ->->........' WHERE `column2` = (..)
I use tab for ident, space for align.
In this way every developer who works on code can have custom settings for his "tab" key - be it 2, 4, 8 or whatver-count chars wide. And code will be readable for all of them.
On Sun, 10 May 2009 06:46:40 +0300 Andris Raugulis ar@null.lv wrote:
I can't remember such a feature. Leading spaces and tabs are generally indentation. And pressing shift+tab removes it. If you re-add it, it only adds the indention type you've configured.
As I mentioned, unchecking "Tab key idents", I get desired results, so, in my opinion, it should be possible for multi-lines, also.
And Now I think I remember that shift+tab was the one that used to work for multiple-lines. Anyway, one way or other (tab or shift+tab), it used to work. I'm pretty sure. Or my memory is broken.
We changed the implementation of indentation when introducing the 'Tabs and Spaces' mode (which is for tab 'compression' of spaces).
Shift+tab just unindents when 'Tab key indents' is enabled.
Anyway, if I can't do this by configuration, how can I achieve my desired results? Snippet, plugin, local patch-branch?
Unfortunately this isn't supported ATM.
In src/editor.c you might be able to modify insert_indent_after_line(), but there are probably other places that need changes too.
Besides, I find it weird to even want such a mixed indentation. Why not use tabs or spaces consistently?
It's not pure identation. It's ident + align. And to answer your question - to make code readable. Consider this code (php example):
->->$sSQL = 'SELECT `column1` ' . ->->........' FROM `table` ' . ->->........' WHERE `column2` = (..)
I use tab for ident, space for align.
In this way every developer who works on code can have custom settings for his "tab" key - be it 2, 4, 8 or whatver-count chars wide. And code will be readable for all of them.
I think this is a reasonable request, but Geany would need to add support for it. Perhaps there could be a pref that only works in tabs or spaces indent mode.
BTW, any idea how much code uses the tabs for indent and spaces for align? I think I ran across some in ctags, so I guess it might be quite popular so the user can use any tab width they like.
Regards, Nick
Anyway, if I can't do this by configuration, how can I achieve my desired results? Snippet, plugin, local patch-branch?
Unfortunately this isn't supported ATM.
In src/editor.c you might be able to modify insert_indent_after_line(), but there are probably other places that need changes too.
I'm not pretty familir with Geany's source, but I could try to implement it. It will be slow, though. Maybe somebody is willing to work on it and it will get implemented faster. Of course, if you're willing to include this feature.
I think this is a reasonable request, but Geany would need to add support for it. Perhaps there could be a pref that only works in tabs or spaces indent mode.
Yeah, it is reasonable, because people do use that style (as you've seen in latest discussions on list). It's applicable when writing SQL code, commenting or in long conditional statements/expressions and function parameters.
I thought about how to implement it and came to conclusion that pref in editor->identation would be the best way. Dunno how it could be named, though. How could it work:
tab: single line -> insert single tab at cursor multi line -> insert single tab at the start of line (ident always starts at the beginning of line)
shift+tab: single line -> (already works fine, removing tab at cursor) multi line -> remove tab from beginning of the line
I think that would cover it, won't it? Or I've made some flaws?
BTW, any idea how much code uses the tabs for indent and spaces for align? I think I ran across some in ctags, so I guess it might be quite popular so the user can use any tab width they like.
I do read *BSD source code (in C) and it doesn't use this particular style, but I have seen in some apps that they do use this coding style. In web apps field, I've seen it quite much.
And yes, the best thing about this coding style is that everybody who works on the code can have custom tab settings and because of space alignment it will be readable no matter what.
On Sat, 16 May 2009 02:28:46 +0300 Andris Raugulis ar@null.lv wrote:
In src/editor.c you might be able to modify insert_indent_after_line(), but there are probably other places that need changes too.
I'm not pretty familir with Geany's source, but I could try to implement it. It will be slow, though. Maybe somebody is willing to work on it and it will get implemented faster. Of course, if you're willing to include this feature.
I'm working on it now, for at least the common actions that need changes. I'll post back to the list when there's something to test.
I think this is a reasonable request, but Geany would need to add support for it. Perhaps there could be a pref that only works in tabs or spaces indent mode.
Yeah, it is reasonable, because people do use that style (as you've seen in latest discussions on list). It's applicable when writing SQL code, commenting or in long conditional statements/expressions and function parameters.
Thanks for the info.
I thought about how to implement it and came to conclusion that pref in editor->identation would be the best way. Dunno how it could be
Yes, I think so.
named, though. How could it work:
tab: single line -> insert single tab at cursor multi line -> insert single tab at the start of line (ident always starts at the beginning of line)
shift+tab: single line -> (already works fine, removing tab at cursor) multi line -> remove tab from beginning of the line
I think that would cover it, won't it? Or I've made some flaws?
I think that should work.
Regards, Nick
On Mon, 18 May 2009 13:18:35 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
named, though. How could it work:
tab: single line -> insert single tab at cursor multi line -> insert single tab at the start of line (ident always starts at the beginning of line)
shift+tab: single line -> (already works fine, removing tab at cursor) multi line -> remove tab from beginning of the line
I think that would cover it, won't it? Or I've made some flaws?
I think that should work.
Implemented in current SVN, please test if possible.
Still to do is making auto-indentation work as expected for tabs+align.
Regards, Nick
On Mon, 18 May 2009 16:26:40 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
tab: single line -> insert single tab at cursor multi line -> insert single tab at the start of line (ident always starts at the beginning of line)
shift+tab: single line -> (already works fine, removing tab at cursor) multi line -> remove tab from beginning of the line
Implemented in current SVN, please test if possible.
Actually I forgot to say: you need to use the geany indent keybindings, which are ctrl-I and ctrl-U by default.
Regards, Nick
Nick Treleaven píše v Út 19. 05. 2009 v 12:01 +0100:
On Mon, 18 May 2009 16:26:40 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
tab: single line -> insert single tab at cursor multi line -> insert single tab at the start of line (ident always starts at the beginning of line)
shift+tab: single line -> (already works fine, removing tab at cursor) multi line -> remove tab from beginning of the line
Implemented in current SVN, please test if possible.
Actually I forgot to say: you need to use the geany indent keybindings, which are ctrl-I and ctrl-U by default.
Regards, Nick _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
Found a little bug: If I try to indent (ctrl-I) multi line and the last line in selection is the last line in the file, then this last line will be not indented.
Key TAB works fine.
Regards, Daniel
On Wed, 20 May 2009 00:07:06 +0200 Daniel Milde info@milde.cz wrote:
Found a little bug: If I try to indent (ctrl-I) multi line and the last line in selection is the last line in the file, then this last line will be not indented.
Thanks, should be fixed now.
Regards, Nick
Nick Treleaven píše v St 20. 05. 2009 v 15:44 +0100:
On Wed, 20 May 2009 00:07:06 +0200 Daniel Milde info@milde.cz wrote:
Found a little bug: If I try to indent (ctrl-I) multi line and the last line in selection is the last line in the file, then this last line will be not indented.
Thanks, should be fixed now.
Regards, Nick _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
Works fine now.
Best regards Daniel
On Mon, 18 May 2009 16:26:40 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
Still to do is making auto-indentation work as expected for tabs+align.
Now implemented in SVN.
Regards, Nick
Nick Treleaven píše v Čt 09. 07. 2009 v 15:23 +0100:
On Mon, 18 May 2009 16:26:40 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
Still to do is making auto-indentation work as expected for tabs+align.
Now implemented in SVN.
Regards, Nick _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
Great news. Thank you!
Regards, Daniel
Nick Treleaven píše v Čt 09. 07. 2009 v 15:23 +0100:
On Mon, 18 May 2009 16:26:40 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
Still to do is making auto-indentation work as expected for tabs+align.
Now implemented in SVN.
Regards, Nick _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
I tried it right now, but don't see any changes. Is it in r3945? Thanks
Daniel
On Thu, 09 Jul 2009 16:52:06 +0200 Daniel Milde info@milde.cz wrote:
Still to do is making auto-indentation work as expected for tabs+align.
Now implemented in SVN.
I tried it right now, but don't see any changes. Is it in r3945?
Yes, only for Tabs indent type. If you have: \t....some text<cursor>
And you press enter and you have auto-indentation turned on, the next line should be: \t....<cursor>
Where \t = tab, . = space.
Regards, Nick
Nick Treleaven píše v Út 14. 07. 2009 v 11:42 +0100:
On Thu, 09 Jul 2009 16:52:06 +0200 Daniel Milde info@milde.cz wrote:
Still to do is making auto-indentation work as expected for tabs+align.
Now implemented in SVN.
I tried it right now, but don't see any changes. Is it in r3945?
Yes, only for Tabs indent type. If you have: \t....some text<cursor>
And you press enter and you have auto-indentation turned on, the next line should be: \t....<cursor>
Where \t = tab, . = space.
Regards, Nick _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
Ah, I tried Tabs and Spaces indention, that's the cause. It works great, thank you :)
Daniel
On Sun, 19 Jul 2009 19:48:20 +0200 Daniel Milde info@milde.cz wrote:
Ah, I tried Tabs and Spaces indention, that's the cause.
Hmm, perhaps we should rename that indent type 'Tab compression' or something. Not sure what's the best term to use.
It works great, thank you :)
:)
Regards, Nick