Kakoune: Middle click paste

Created on 8 May 2020  路  8Comments  路  Source: mawww/kakoune

Feature

Middle click paste in terminal.

Usecase

Press middle click to paste contents from primary clipboard, currently only can use shift insert in insert mode or shift middle click to paste but not without shift.

feature request

Most helpful comment

hook global RawKey <mouse:press:middle:.*> exec !xclip<space>-o<ret> should do the trick on latest master

All 8 comments

If you disable Kakoune's mouse support:

set-option -add global ui_options ncurses_enable_mouse=off

...then drag-to-select and middle-click will be handled by the terminal and not by Kakoune, and should work as you expect.

Unfortunately, terminals do not provide any way for Kakoune to read the contents of the primary clipboard, so with mouse support enabled it's not possible for middle-click (without shift) to paste.

We could extend Kakoune to support the middle mouse events, then the user could map those to whatever shell command is able to read the primary clipboard in insert it.

@Screwtapello Nice, that works but it disabled the mouse. Either way, I don't use the mouse anyway so it worked for me.

Personally, I've found I hold down Shift whenever I select or paste text in the terminal, whether I'm in an editor or just at the shell prompt.

@Screwtapello Shift works too but I need to press shift which I usually don't, middle clicking on my laptop (thinkpad) is easier, just below the space bar.

Oh, I just realized when pasting, it still auto-indent which messes up the indentation from pasted code, every time I need to fix the indented code manually from python after pasting.

You can go into insert mode with hooks disabled, for example with \i, before pasting to disable auto-indentation. Ideally we would have bracketed paste mode like in #2465 so Kakoune can figure out we are pasting rather than typing.

hook global RawKey <mouse:press:middle:.*> exec !xclip<space>-o<ret> should do the trick on latest master

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hwmack picture hwmack  路  4Comments

vbauerster picture vbauerster  路  3Comments

alexherbo2 picture alexherbo2  路  3Comments

basbebe picture basbebe  路  4Comments

valerdi picture valerdi  路  4Comments