sublimetext2 - Shortcut to change a line of words to a vertical list in Sublime Text 2 -


enter image description hereis possible make title on line 1 list of items each word or symbol seperated space keyboard shortcut. can select title , hit shortcut , make title list of items below:

enter image description here

tried saving key binding file.

nothing built in, can plugin.

import sublime import sublime_plugin import re   class splitlinecommand(sublime_plugin.textcommand):     def run(self, edit, split_pattern=" "):         view = self.view         cursors = view.sel()         if len(cursors) == 1:             cursor = cursors[0]             begin_offset = 0             end_offset = 0             if cursor.empty():                 region = view.line(cursor)                 content = view.substr(region)                 new_content = re.sub(split_pattern, "\n", content)                  view.replace(edit, region, new_content)             else:                 region = cursor                 content = view.substr(region)                 new_content = ""                 if view.line(region).begin() != region.begin():                     new_content = "\n"                     begin_offset = 1                 new_content += re.sub(split_pattern, "\n", content)                  if view.line(region).end() != region.end():                     new_content += "\n"                     end_offset = - 1              view.replace(edit, region, new_content)             cursors.clear()             cursors.add(sublime.region(region.begin() + begin_offset, region.begin() + len(new_content) + end_offset))             view.run_command("split_selection_into_lines") 

you can add following in key binding file.

[     { "keys": ["f8"], "command": "split_line", "args": {"split_pattern": " "}} ] 

of course changing key want. don't need args argument if using space. defaults that. included completeness.

edit: i've updated plugin handles selections, though not handle multiple cursors @ point.

edit 2 if not working, try opening console , entering view.run_command("split_line"). run command in whatever view in prior switching console. way know if command works. if doesn't there problem plugin. if does, there problem key binding.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -