Sublime Forum

Transforming Multiple Selections into Lines

#1

Informal docs say:

On my 64-bit Ubuntu system, ST3/3054, Ctrl+L expands the selection to the whole line, and Ctrl+Shift+L doesn’t appear to do anything. :astonished:

The doc page is:
http://docs.sublimetext.info/en/latest/editing/editing.html#transforming-multiple-selections-into-lines

0 Likes

#2

ctrl+shift+l turns one multiline selection into multiple one-line selections. What are you expecting it to do?

0 Likes

#3

When I select a block of 5 lines and type ctrl shift L, nothing appears to change. It looks the same. So I type one letter and all 5 lines are replaced by the 1 letter. If it were really a series of multiple selections then the number of lines would not have reduced to 1.

0 Likes

#4

Open up console, type:
sublime.log_commands(True)

keep console open, select the block of lines, and ctrl+shift+l, paste the output from console.

0 Likes

#5

sublime.log_commands(True)
command: drag_select {“event”: {“button”: 1, “x”: 63.5, “y”: 268.5}}

(Everything after this was my attempt to copy for pasting. Doing the select first, then setting log_commands to True, then ctr+shift+l results in nothing being logged at all).

List bound keys shows:

|ctrl+a                   |select_all               |                         |                                                  |
|ctrl+shift+l             |split_selection_into_lin…|                         |                                                  |
|escape                   |single_selection         |                         |                                                  |

So I’m puzzled.

0 Likes

#6

Don’t use mouse to select the text.

Try:
-Open the console
-Type sublime.log_commands(True)
-Clic somewhere on the file to put the cursor (focus).
-Hit shift-down 2 times to extand selection
-Hit ctrl+shift+l

The result in the console must be something like:

>>> sublime.log_commands(True) command: drag_select {"event": {"button": 1, "x": 314.5, "y": 409.5}} command: move {"by": "lines", "extend": true, "forward": true} command: move {"by": "lines", "extend": true, "forward": true} command: split_selection_into_lines

0 Likes

#7

sublime.log_commands(True)
command: drag_select {“event”: {“button”: 1, “x”: 53.5, “y”: 261.5}}
command: move {“by”: “lines”, “extend”: true, “forward”: true}
command: move {“by”: “lines”, “extend”: true, “forward”: true}

===
Again, showing the line after, which is from ctrl+backquote:

sublime.log_commands(True)
command: drag_select {“event”: {“button”: 1, “x”: 53.5, “y”: 145.5}}
command: move {“by”: “lines”, “extend”: true, “forward”: true}
command: move {“by”: “lines”, “extend”: true, “forward”: true}
command: show_panel {“panel”: “console”, “toggle”: true}

===
I tried again, thinking maybe I’d got it all wrong, maybe the command is control-shift-eye, not control-shift-ell, but no, it’s ell, the letter after kay.

By the way, is there a way I can enter into the console: split_selection_into_lines ?

Also, thanks for all your effort so far…
RickyS

0 Likes

#8
sublime.active_window().active_view().run_command("split_selection_into_lines")
0 Likes

#9

command: move {“by”: “lines”, “extend”: true, “forward”: true}
command: move {“by”: “lines”, “extend”: true, “forward”: true}
command: drag_select {“event”: {“button”: 1, “x”: 206.5, “y”: 707.5}}

sublime.active_window().active_view().run_command(“split_selection_into_lines”)
command: drag_select {“event”: {“button”: 1, “x”: 56.5, “y”: 268.5}}

I can see a visual change when I enter the command. This is different from the result of entering ctrl+shift+l.
But when I move the mouse focus back to the pre-selected lines, everything gets de-selected so I don’t get any useful result.

Ah! I move the focus back by re-entering ctrl+backquote and then enter the letter a. Each of the three selected lines got changed into a single letter a.
Proving the lines were selected as multiple selections:

sublime.log_commands(True)
command: drag_select {“event”: {“button”: 1, “x”: 57.5, “y”: 269.5}}
command: move {“by”: “lines”, “extend”: true, “forward”: true}
command: move {“by”: “lines”, “extend”: true, “forward”: true}
command: move {“by”: “lines”, “extend”: true, “forward”: true}
command: show_panel {“panel”: “console”, “toggle”: true}

sublime.active_window().active_view().run_command(“split_selection_into_lines”)
command: show_panel {“panel”: “console”, “toggle”: true}
command: hide_auto_complete
Writing file /home/ricky/addtopathOld.sh with encoding UTF-8 (atomic)

Is there a way I can fix my (apparently) broken key-map? or maybe write a macro to implement this? Or should I just file a bug somewhere?

0 Likes

#10

Try to log inputs with:

>>> sublime.log_input(True) key evt: control+alt+l
Maybe this keybinding is trapped by OS or something else.

0 Likes

#11

ctrl-shift-L does not appear, ctrl-shift-K does appear:

sublime.log_input(True)
key evt: shift+control+k[/code]

So I took a look at the output of xev.  The two keystrokes appear QUITE DIFFERENTLY:

**First Ctrl+Shift+K, key-up and key-down:**
[code]KeyPress event, serial 28, synthetic NO, window 0x6800001,
root 0x91, subw 0x0, time 20311193, (146,80), root:(1507,132),
state 0x15, keycode 45 (keysym 0x4b, K), same_screen YES,
XLookupString gives 1 bytes: (0b) "
"
XmbLookupString gives 1 bytes: (0b) "
"
XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x6800001,
root 0x91, subw 0x0, time 20311305, (146,80), root:(1507,132),
state 0x15, keycode 45 (keysym 0x4b, K), same_screen YES,
XLookupString gives 1 bytes: (0b) "
"
XFilterEvent returns: False

Now Ctrl+Shift+L, key-up and key-down are only one event!

KeymapNotify event, serial 28, synthetic NO, window 0x0, keys: 4294967185 0 0 0 32 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
So I think something is mis-configured or broken in Ubuntu…

0 Likes

#12

This problem magically went away when I wasn’t looking. Thanks for the help…

0 Likes