Search code examples
sublimetext2sublimetext3sublimetextsublime-text-plugin

Paste multi-cursor copy/paste WITHOUT newlines in sublime text


Is there a way to paste a multi-cursor (Ctrl+d, Ctrl+d, ... Ctrl+C) select, stripped of its newlines?

If [...] represents the highlight, and the cursor:

The ⦙[red].
The ⦙[blue].
The ⦙[green].

And if I pasted I'd get:

red
blue
green⦙

but instead I want

redbluegreen⦙

Is this possible?


Solution

  • Save the following script @:
    /Packages/Paste Without NewLines/paste_without_newlines.py

     

    import sublime, sublime_plugin
    
    class paste_without_newlines( sublime_plugin.TextCommand ):
        def run( self, edit ):
    
            clipboard = sublime.get_clipboard()
            clipboard = clipboard.replace( "\n", "" )
            sublime.set_clipboard( clipboard )
            self.view.run_command( "paste" )
    

     


     

    To execute via Command Palette > Paste Without NewLines, add the following code @:
    /Packages/Paste Without NewLines/Default.sublime-commands

     

    [
        {
            "caption": "Paste Without NewLines",
            "command": "paste_without_newlines",
        },
    ]
    

     


     

    To execute via Ctrl + Shift + Alt + V, add the following code @:
    /Packages/Paste Without NewLines/Default.sublime-keymap

     

    [
        {
            "keys": ["ctrl+shift+alt+v"],
            "command": "paste_without_newlines",
        },
    ]