How Can I Join Lines of Text?

can Texmacs join lines together similar to the way sublime text joins lines with the ctrl+shift+j shortcut? I frequently need to paste multi-line text into a document but require the text to appear as a single line.

Hi @wiel and welcome to the forum. One way IMO is by getting the clipboard content into Scheme, then using Scheme functions to substitute spaces for line breaks. I would wait and see if someone has a better idea before I develop this, though.

I don’t know of a single command that does this. But I use this routine bound to J:

(begin (kbd-end-line)
           (kbd-select kbd-right)
           (kbd-cut))

I don’t have time to lookup how to bind it, but you can try placing something like:

(kbd-map 
  ("J" (begin (kbd-end-line)
           (kbd-select kbd-right)
           (kbd-cut))))

In your init file. I does move the cursor to the end of the line though. I have some macros that restore the cursor position, but that might be unreliable, since depending on what you delete, the cursor position may become invalid. Try using the simple one above.

P.S: “J” is shift+j. If you want Ctrl+Shift+j, then try changing “J” to “C-J” in the above kbd-map command.

1 Like