Sublime Forum

Replicating insert functionality of ctrl+x

#1

When you cut or copy without a selection, the current line is taken. You can then click anywhere in another line, and pasting will insert the taken line above the current line. Is there a way to trigger this functionality in a plugin? Looks like there is some internal variable in Sublime Text that gets set to mark the copied text for this functionality. I’m attempting to replicate the behavior of the Line Cut function in VS (ctrl+l).
Any help is appreciated.

0 Likes

#2

No idea how the line cut function is VS works, but as for a ST plugin, you could move the cursor to the beginning of the current line (see view#line). Then insert your content and a new line. Finally, you could place the cursors back where you expected.

If you haven’t done much with a text command before, I’d guess you would be working with view#sel, selection#add, and selection#clear.

0 Likes

#3

You can find most of the commands in the default keybindings file (Preferences -> Key Bindings - Default)

Those commands can be called as a macro (I’ve never tried it) or as Plugin. Check out docs.sublimetext.info/en/latest/ … mands.html

0 Likes

#4

Thanks for your replies. I realized what I was trying to do won’t be possible without some c code, as it involves manipulating the OS clipboard.

0 Likes