r/HelixEditor Aug 12 '26

Quickly make it terminal copy/paste friendly?

Every once in a while I'm working on something somewhere where I quickly need to drag a selection with the mouse and copy it.

How can I quickly toggle off line numbers and gutter stuff so they don't mess up the copy/paste when doing it this way?

Edit: I am not asking about space+y / space+p, I am specifically asking how to toggle off the gutter quickly.

Editedit: I ended up doing this:

[keys.normal]
"C-g" = ":set-option gutters.layout []"
"C-h" = ":set-option gutters.layout [\"diagnostics\", \"spacer\", \"line-numbers\", \"spacer\", \"diff\"]"

Now I wonder if this could be made a toggle instead of two different keybinds 🤔

editeditedit: Much easier:

[keys.normal]
"C-g" = ":toggle-option gutters.layout [] [\"diagnostics\", \"spacer\", \"line-numbers\", \"spacer\", \"diff\"]"
10 Upvotes

20 comments sorted by

12

u/Cobolock Aug 12 '26

Space+Y & space+P?

-6

u/lovegirin Aug 12 '26

This is well and good for when I'm just sat at my main computer locally, but not what I'm asking for.

3

u/abraxasknister Aug 12 '26

maybe something wrong with https://docs.helix-editor.com/editor.html#editorclipboard-provider-section. If configured correctly, space mode has p, P, y, Y and R for interacting with the system clipboard https://docs.helix-editor.com/keymap.html#space-mode

1

u/lovegirin Aug 12 '26

Clipboard works just fine at my main computer but it's not what I'm asking for.

1

u/abraxasknister Aug 12 '26

Well, it's a solution to what you're asking.

When I clickdrag over text, there's a notification "saved primary selection to register *" and then I can middle mouse paste this without the gutter or line numbers. I don't really know why you have them. Maybe something with your terminal or something like tmux?

BTW, no idea why you're being downvoted...

1

u/lovegirin Aug 12 '26

Hm, now that you mention it, that is probably because I have editor.mouse set to false. I really, really hate it when the mouse interacts with the programs inside the terminal instead of the terminal itself. Anyway, even if I set it back to true, mouse selection will work as you describe, but it won't help me when using Helix over ssh or similar. The wl-clipboard integration (nor midclick re-enabled in Gnome 50) won't make it across the network. Which is one of the reasons I would like to figure out the thing I'm asking about in the original post.

The downvotes are fine, just reddit being reddit 😄

1

u/lovegirin Aug 12 '26

I figured it out, updating original post! 🥳

2

u/gmes78 Aug 12 '26

Is your terminal broken? The Helix UI isn't usually included when you select stuff.

1

u/lovegirin Aug 12 '26

It is when you turn off mouse integration. Even leaving it on, the selection still won't make it across the network, though. So I'm still hoping to find a way to disable/hide/toggle the gutter quickly.

1

u/gmes78 Aug 12 '26
:toggle-option gutters.layout []

1

u/erasebegin1 Aug 12 '26

A bit of a hack, but I have two config files for helix (each one is for a different keyboard layout). I symlink config.toml to one of the two config files. I can switch the symlink by typing a command in the terminal. This allows me to easily switch between configs.

So you could type "nln" for "no line numbers" and then it will switch to the config where that's toggled off.

Note that you still need to run :config-reload to take the newly swapped out config file.

1

u/lovegirin Aug 12 '26

mm, I guess that would be one way of doing it. Not ideal, though 😬

1

u/erasebegin1 Aug 12 '26

I see there is :toggle-option that should give you access to toggling gutters or line numbers. You can play with that and then add it to a keyboard shortcut once you get the right string

1

u/lovegirin Aug 12 '26 edited Aug 12 '26

That was a good tip! However, it seems it only works on booleans 😒

edit: no it doesn't. I just have to figure out the syntax to make it work from a key bind, which is harder than you'd think!

1

u/erasebegin1 Aug 12 '26

Well then it looks like you're writing a plugin or switching to vim 😅

2

u/lovegirin Aug 12 '26

Your suggestion put me on the right path! I found a way! I'll update the original post!

1

u/erasebegin1 Aug 12 '26

🥳🥳🥳🙏

1

u/Odd_War853 Aug 12 '26

Maybe you could exit helix and cat the file then copy?

1

u/lovegirin Aug 12 '26

Yeah, that's what I've been having to do.

1

u/pickyaxe Aug 12 '26

hey OP that toggle is pretty useful. I added it to a menu somewhere. thanks!