vkocubinsky / SublimeTableEditor

This package is no more supported. I moved to vim.
Other
494 stars 67 forks source link

Automatic re-alignment while writing in a table? #63

Open josephernest opened 7 years ago

josephernest commented 7 years ago

Hi @vkocubinsky , I know that the plugin is no more supported because you moved to vim, but maybe you do remember about this:

Currently, after each keypress in a table, the table alignment is broken, until you press <TAB>, and then the alignment is restored.

4

How would it be possible to have auto-re-alignment after each keypress?

Do you remember where is the "keypress event listener" in your .py files? Should we trigger "table-re-align" (what's the function name for that?) there?

vkocubinsky commented 7 years ago

Hi @josephernest , not sure that I remember correctly, but I guess that files:

Default (Linux).sublime-keymap
Default (OSX).sublime-keymap
Default (Windows).sublime-keymap

are entry point for plugin. Let's look for example into OSX

   ...
    { "keys": ["ctrl+shift+a"], "command": "table_editor_align", "context":
        [
            { "key": "setting.enable_table_editor", "operator": "equal", "operand": true, "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*\\|", "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "$", "match_all": true }
        ]
    },
    ...

Table Editor maps ctrl-shift-a key to table_editor_align command if line looks as a table. Command table_editor_align defined in table_plugin.py as a class TableEditorAlignCommand which is sublime_plugin.TextCommand, this is name convention, see about sublime plugins here https://code.tutsplus.com/tutorials/how-to-create-a-sublime-text-2-plugin--net-22685.

What you want is automatically run "table_editor_align" command after any alpha numeric keys for lines which looks as a table. I am not aware how to do this, but you can investigate into this if you like. Probably click ctrl+shift+a manually after type a word is the workaround for you.

Thanks!

keith-hall commented 7 years ago

http://stackoverflow.com/a/42268109/4473405 details how to align the table after any alphanumeric keypress