Repository navigation
autoindent lines with moveLineUp/moveLineDown - #9104
Conversation
|
Shouldn't there be an option in settings for that? |
It looks like it already respects the existing |
|
Could you add a test for this @joseramonc? |
|
@maxbrunsfeld if so, it would be nice to have this metioned in setting description |
|
@maxbrunsfeld Added tests for |
|
Sorry for letting this go quiet for a while; there were some network-related CI failures. I re-ran the build. |
|
@maxbrunsfeld It seems that just one build failed, is there some guide or help to debug this locally? Tests are passing on my computer 😞 |
|
You can safely ignore the symbols-view error; that spec is super-flaky right now. |
|
@joseramonc Thanks for the ping. Great work! |
autoindent lines with moveLineUp/moveLineDown
|
@joseramonc Thanks for this great feature, love it 🎉 |
|
Thanks a lot for your contribution but this breaks a pretty common use case : https://discuss.atom.io/t/move-line-without-auto-indent/23754 Original message :
|
|
Perhaps an option to disable auto-indent when moving lines in plain-text files? |
|
@as-cii As per the gif @dorian-marchal just posted, I'd say auto-indent shouldn't trigger when changing lines from the same "lexical" line. Or make it understand what lexical line breaks are and make it work accordingly. |
|
OK, it looks like this feature seems to have undesirable consequences pretty often, even in contexts where auto-indent is desirable for text insertion. @joseramonc I think we may need to remove this feature until Atom's auto-indentation system is good enough to avoid these problems. |
|
Just like @dorian-marchal has demonstrated this feature wreaks havoc on indentation for code spanning multiple lines. It would be nice to have a separate setting to enable or disable auto-indent specifically for this feature. EG: "editor.indentOnLineMove", when set to false it won't automatically indent but editor.autoIndent will remain untouched/active. @dorian-marchal I kludged it with this custom command. atom.commands.add 'atom-text-editor', 'my:move-line-up', ->
editor = atom.workspace.getActiveTextEditor()
if atom.config.get('editor.autoIndent')
atom.config.set('editor.autoIndent', false)
editor.moveLineUp()
atom.config.set('editor.autoIndent', true)
else
editor.moveLineUp()
atom.commands.add 'atom-text-editor', 'my:move-line-down', ->
editor = atom.workspace.getActiveTextEditor()
if atom.config.get('editor.autoIndent')
atom.config.set('editor.autoIndent', false)
editor.moveLineDown()
atom.config.set('editor.autoIndent', true)
else
editor.moveLineDown()and keymap '.platform-linux atom-workspace atom-text-editor:not([mini])':
'ctrl-shift-up': 'my:move-line-up'
'ctrl-shift-down': 'my:move-line-down' |
|
@snowsunny It works just fine, thank you 👍 |
|
@dorian-marchal I’m happy to help 👍 |
|
Maybe make this an option ? It seems useful for people that mostly use language with clear indent scoping block (like html, JavaScript) I also feel that re-arranging item in hanging indent is somewhat rare. |
|
Making this an option sounds 🆒 to me – that way we could scope it only to grammars that play nicely with this. |
|
Adding another vote for making this a separate option from auto-indent. For someone who moves multiple lines regularly, this is a real killer. In the meantime, thanks to @snowsunny for the workaround. |
|
In what kind of scenario auto-indent works well but this does not ? |
|
Yes please for separating this into its own flag. @snowsunny is that only for linux or for mac as well? |
|
@eddiemonge Please try this keymap. # for mac
'.platform-darwin atom-workspace atom-text-editor:not([mini])':
'ctrl-cmd-up': 'my:move-line-up'
'ctrl-cmd-down': 'my:move-line-down' |
|
This can be pretty dangerous when writing python. For example, moving a line from above an Definitely needs to be an option, and probably off by default in python - and I'd imagine any other language with significant whitespace. In the meantime, thanks @snowsunny - you are my internet hero of the day. There is now a related issue where this is being discussed further: #10524 |



Related to #7546, added the
autoIndentSelection if should autoIndent. A demo of the change: