demon386/SmartMarkdown

Feature: Quick nested list indenting

jeffnuss opened this issue · 13 comments

It would be nice if I could just hit tab when I have a list item and increase the indentation level. Also, I know shift-tab folds the headings up, but maybe shift-alt-tab or something else to decrease the indent level. I use your plugin for note taking and it's great. Thanks.

Thanks for your suggestion. I'll work on it when I have time.

A simple of version of feature can be accomplished by add the following to the bottom* of SmartMarkdown/Default.sublime-keymap:

    { "keys": ["tab"], "command": "indent", "context":
        [
            { "key": "selector", "operator": "equal", "operand": "markup.list" }
        ]
    },
    { "keys": ["shift+tab"], "command": "unindent", "context":
        [
            { "key": "selector", "operator": "equal", "operand": "markup.list" },
            // Should we enable the following setting check?
            // { "key": "setting.shift_tab_unindent", "operator": "equal", "operand": true }
        ]
    }

* The position is important: as it should override the Shift+Tab global fold. I actually don't like that binding very much, but I'm not sure if something else would be an improvement.

Edit: Ah, I see the commit I made in my branch triggers a comment here. Well, the commit just includes the code above.

Scratch that. The default Markdown syntax does not play very nice when the caret is at the end of the document like so:

* List
* |

I cobbled together an improved version using regex, which includes support for (almost) all of the various Pandoc lists: 1b5c095

Testers?

Wait, you know there are ctrl+[ and crtl+] - works everywhere and exactly as you expect?

I mean, sure maybe other keystrokes would be more convinient, but implicitness is bad:
if I press shift+tab in list it will unindented... but I meant to fold all;
if I press shift+tab in paragraph it will fold... but I meant to unindent.

See?

ctrl/command + [ and ] certainly work, but my use case comes from experience with word processors such as microsoft word where hitting tab at the beginning of a bulleted list item indents that item. Tab indentation is nice because it's a learned behavior from other programs. ctrl/cmd + [ and ] are fine when I'm coding, but when I'm taking notes or quickly inputting items in a list that will be turned into HTML, it's nice to just hit enter then tab to quickly nest a list. Also, you could use shift+alt+tab instead of shift+tab or leave it up to the user to decide. I'd personally use shift+tab to unindent more than I would to fold all, but certainly that's just me and what I use markdown for.

@jeffnuss I understand, e.g. I had used Tomboy for a long time.
But you know how they say: the further into the woods, the more firewood.

  1. shift+alt+tab switches windows in Windows (at least 7)

  2. plain text doesn't make good alignment (as e.g. MS Word or Tomboy) so if one want to make it they should use whitespaces or tabs
    example of alignment:

*   First paragraph.

    Continued.

*   Second paragraph.

Now it may be acomplished just by hitting tab.

So I just saying that such small issue will demand too much time for making, testing, and configuring - does it really worth it, taking in account of ctrl+[/]?

Let me throw in a couple of thoughts:

I get what @vovkkk is saying in terms of testing, but I think that, with a little fine-tuning, what I have posted above is okay for most use. (Unless I've missed something blindingly obvious.)

Now, if the objection is that it breaks expected behaviour, it's very simple to hide it behind a setting such as "quick_indent_lists" for those of us who prefer it. I think this situation is more of an issue with the Emacs-heritage of the fold/unfold all binding, since these bindings are quite Sublimish.

Also, they may look the same but what Ctrl+[ & Ctrl+] do is to push and pull the beginning of the line. Whereas Tab subordinates the idea on the current line to the idea on the previous one, while Shift+Tab makes the current line's idea parallel to an earlier one.

I'm not kidding. It would be great if it was possible to move logical units around using Ctrl+Shift+Up/Down. Any takers?

@jeffnuss If you use the bindings, let me know how it goes :)

Got a chance to play with the bindings and they work great. This is exactly what I was looking for. Thanks.

Cool. Let me know if you notice any weirdness. I just squashed a bug @vovkkk pointed out to me (hopefully, for good) that was interfering with folding headings. Just grab the last two keybindings from here: https://github.com/alehandrof/SmartMarkdown/blob/develop/Default.sublime-keymap

@demon386 I've been using this for awhile and it's both useful and robust (I think). Shall I open a PR?

I haven't been actively pounding on it and trying to break it, but I haven't had an issues with it, so you have my vote.

I'm putting together a package of Markdown stuff I've made for my own use. If @demon386 isn't interested (which I can understand, as SmartMarkdown does some higher-level stuff) I will publish these in that form for easy update & maintenance.

@alehandrof This functionality is good (in fact Org mode has that too)! Please submit a PR is possible. Thanks!