If I yank a word in kakoune, how do I paste it into another editor (e.g. gedit)?
Look at this entry: https://github.com/mawww/kakoune/wiki/Registers-&-Clipboard#using-the-system-clipboard
On Macos this works also
hook global NormalKey y|d|c %{ nop %sh{
printf %s "$kak_reg_dquote" | pbcopy
}}
has this been implemented? im interested in using kak for small simple editing but actually having to configure the most basic of functionalities is offputting
It has not. But configuring this should not be that difficult:
map global user y '<a-|>xclip -i -selection clipboard<ret>'
Now if you hit ,y it will be yanked to your clipboard.
Assuming you want to also paste things into kakoune from your clipboard here is the line for that:
map global user p '!xclip -o<ret>'
Similarly you use ,p to paste into kakoune from the clipboard.
@mawww is there any hope of making this build-in with some simple command? I followed this: https://stackoverflow.com/a/42296453/10898116 and got copy/paste working, but it seems fairly elaborate (required installing xsel, for starters) and might turn people away from kakoune. Maybe it's more technically difficult than I appreciate?
copying one snippet and installing one program is complicated?
More complicated than just a snippet, which in turn is more complicated than "it just works the way I expect". These things are always relative.
# Yank
hook global NormalKey '[ydc]' %{
nop %sh{
(printf '%s' "$kak_main_reg_dquote" | xclip -filter | xclip -selection clipboard) < /dev/null > /dev/null 2>&1 &
}
}
# Paste
map global user p -docstring 'Paste (After)' '<a-!>xclip -out -selection clipboard<ret>'
map global user P -docstring 'Paste (Before)' '!xclip -out -selection clipboard<ret>'
map global user R -docstring 'Replace' '|xclip -out -selection clipboard<ret>'
@SolitudeSF If it's quite hard to build basic copy/paste functionality into the kakoune by default, then that's completely understandable. If not, then it's obviously a needless complication for users that should be addressed.
It'd be pretty easy for, say, Cygwin's clipboard support, where you can just read and write /dev/clipboard.
It'd be a bit more complex for macOS, since you can shell out to pbcopy and pbpaste, but I'm not sure if/how those work if you're running code on a macOS box via SSH instead of via the GUI.
It'd be more complex yet again for X11, since X11 doesn't provide a place to store clipboard data, it just stores "which application last copied", so the application has to stay running at least until some other application copies. Since Kakoune is single-threaded, long-running, blocking processes are annoying (although not impossible) to deal with, as in #2325.
It'd be even more complex for Wayland, since for security reasons Wayland only allows an application to copy to the clipboard while it's processing an input event, like a mouse-click on a "copy" toolbar button, or a "Ctrl-C" keyboard event. Since Kakoune runs inside a terminal, it never gets to see Wayland input events, and so it couldn't interact with the clipboard... EXCEPT that most Wayland servers are running XWayland, so you can just use the X11 solution, EXCEPT that XWayland is not guaranteed to be present, and Kakoune would probably fail in a very confusing and difficult-to-debug fashion in that case.
Supporting all of the above would be much more complex than any of them individually, just because new features are always multiplicative rather than additive.
As a point of comparison, Vim decided to take on the complexity of multiple native ports long ago, so it already supports all those clipboard APIs and more. In fact, Vim's so portable that one of the early goals of the NeoVim fork was to make it less portable, in the name of maintainability. From that point of view, Kakoune's already way ahead of the curve, since it only supports one platform, POSIX. Sadly, the POSIX standard doesn't include any kind of clipboard API.
Assuming you want to also paste things into kakoune from your clipboard here is the line for that:
map global user p '!xclip -o<ret>'Similarly you use
,pto paste into kakoune from the clipboard.
In addition to @bhajneet answer, you might want to also use the proper selection for pasting. For me it was causing the use of "middle-click clipboard" instead of the "classic one".
map global user y '<a-|>xclip -i -selection clipboard<ret>'
map global user p '!xclip -selection clipboard -o<ret>'
Most helpful comment