[Top][All Lists]

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

Re: Indentation of current line or selected blocks in the code editor?

From: John W. Eaton
Subject: Re: Indentation of current line or selected blocks in the code editor?
Date: Tue, 14 Nov 2017 17:01:37 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 11/08/2017 05:44 PM, John W. Eaton wrote:
On 11/08/2017 03:56 PM, Torsten wrote:

There is some smart indentation while typing
(octave_qscintilla::smart_indent). Maybe we can use parts of it for
"offline" adjusting the indentation.

Thanks for the pointer.

Here's what I have so far:


I pushed it even though it is not complete so that it would be easier to test. It only adds code and doesn't modify an existing behavior.

Currently, this new indent feature is not connected to any keyboard shortcut yet and is only accessible from the Edit -> Format menu in the editor. What keybinding should it use by default?

I'm sure there is a lot of room for improvement since this is very simplistic. You can easily fool it by having multiple block (begin or end) keywords on a single line. Only the first will be noticed, so indentation will probably not be correct. It does not attempt to detect mismatched begin/end pairs (for matched by endif, for example). But it does appear to work correctly for me with well-formed code. It will work on a single line (where the cursor is) or on a block of selected text.

It probably should be limited to Octave code since it uses regexps that are for Octave syntax, not other languages. I'm not sure how the editor works for different types of files.

Comments, help, and suggestions welcome.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]