[Geany-Devel] Some Auto-Indentation Ideas
rbooth at xxxxx
Thu Mar 14 13:41:41 UTC 2013
On 03/13/2013 09:42 PM, Braden Walters wrote:
> I had some ideas for some keybindings or settings that could help with
> some indentation issues. I'm willing to implement them myself, but I
> wanted to see what the other developers think first. First, the reason
> why I want to even write these.
> I work on multiple projects, some of which have multiple developers
> and some where whitespace has been left all around some files. I
> generally use manual indentation (no auto-indent at all), and I can't
> help but think there's something better I could do. I could use the
> current character indent, but then I'll have trailing whitespace
> everywhere, or I'll have to backspace that out manually (sort of
> defeats the purpose). I could turn on "Strip trailing whitespace", but
> that's going to modify a lot of lines I never really changed.
> Here are some solutions I've thought up:
> - Keybindings for everything approach: Improve the "smart indent" key
> binding to just use the global (or project if available) settings for
> auto-indentation upon striking the key combination. Then, create a key
> binding that removes all contents from a line, but does not delete the
> line itself.
> - Strip on return approach: Create a global/project settings option to
> strip whitespace from the current line upon striking return.
I've worked as a developer in teams of programmers. I've never seen
examples of "where whitespace has been left all around some files".
Occasionally I see spaces at the end of lines. That doesn't bother me much.
My main whitespace complaint with Geany is the indentation whitespace
auto-generated when I leave blank lines. So if I am at one tab
indentation and I type return, return, the line above the caret contains
one tab only.
The editor I used when I developed on Windows, Codewright, allowed
moving the caret into virtual space, as does Geany. But when I hit
return, Codewright put the caret in virtual space on the new line. Only
when I typed a character did Codewright fill in the virtual space from
bol using my chosen indentation policy. So if I am at one tab
indentation and I type return, return, the line above the caret is
completely empty. The drawback is that the caret is at the left margin,
since the previous line's indentation was zero. But I found that
preferable to Geany's. I always felt Codewright's behavior could have
been improved to eliminate even this imperfection.
I did play around with Geany's various white-space removal options. But
when submitting patches I was worried that the group to whom I submitted
the patch might object to gratuitous changes. Also, I tend to save
often, and each time I would save, the caret would snap back one and the
space I typed after the last token would be lost. Irritating.
I vote for Codewright's approach, with or without the improvement.
> Both of these approaches introduce a problem though. If I remove
> whitespace from a line, I return back to a column position of zero.
> The auto-indent modes I've used will therefore make the following line
> 0 columns indented. One solution to this could be to auto-indent up to
> the last indented line, if available. I'm sure there are other
> solutions to this though.
> So I propose three questions in this email. First: Is this something I
> should even be making for an upstream core feature, or should it be in
> a plugin? Second: Which of my two approaches seems more reasonable?
> Third: Are there any other solutions anyone has to the final problem I
> mentioned, or will the solution I proposed suffice?
> Sorry for the length of this e-mail, everyone.
More information about the Devel