Live data from Hacker News

Tmux and Vim – better together

blog.bugsnag.com

21–30 of 297 posts

Re: Tmux and Vim – better together

#21
post #2

I've shyed away from using tmux and Vim. For some reason, when I use tmux and Vim, if I 'copy' a snippet of text (using my mouse/cursor higlight -> right-click -> copy) it treats all of the empty space a actual "space" characters when I 'paste'. Why does it do this?

Because when you are selecting, that usually means that you let the terminal select from the contents of the terminal buffer. And vim is out of the game. It may for example be that your vim draws actual spaces to fill each line for rendering on the terminal. What you describe doesn't happen for me on xterm+vim and neither on xterm+tmux+vim, but it may well happen on a another terminal or with different vim settings.

You can let vim catch the mouse clicks / drags and have it manage you X11 clipboard (start looking at vim help for :set mouse=...). Personally I prefer to not have vim mess with my mouse and X11.

I think it's better to just use vim's horizontal selection ("visual line", Shift+v) and use yank (y key) or filter it into an extern command like "xlip -i -selection clipboard" to copy the highlighted text into the clipboard.

Re: Tmux and Vim – better together

#22
Not sure if it is only at my Mac, but with the latest Mac OS + iTerm + TMUX + VIM, my clipboard doesn't work properly, even using the following setup on my tmux

bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

Anyone with the same problem?

Re: Tmux and Vim – better together

#23
post #5
post #3

I love TMux and Vim and I miss it when off my machine. Has anyone used TMux in the Creator's Edition of Windows 10? It is AWESOME. I need to get CMUS and Ranger working and I will be a happy camper.

I used it for a while but then I realized that ConEmu also supports split panes, and then i can just scroll/select the buffers by mouse instead of ctrl+b, [. ConEmu really is an amazing piece of work. Quirky to configure (but hey, so it tmux), but truly amazing still :-)

You can scroll using mouse in tmux too. :set mouse

Not sure about selecting panes with mouse though

Re: Tmux and Vim – better together

#26
post #2

I've shyed away from using tmux and Vim. For some reason, when I use tmux and Vim, if I 'copy' a snippet of text (using my mouse/cursor higlight -> right-click -> copy) it treats all of the empty space a actual "space" characters when I 'paste'. Why does it do this?

I don't know if this will solve your problem, but you can try

  set clipboard=unnamedplus
Then all yanking and deleting will put the yanked or deleted text in the X11 clipboard, from whence you can paste it in other applications, including terminals. For more information try

   help registers
I use this all the time, and find it essential (no mouse required).

Re: Tmux and Vim – better together

#27
post #14
post #2

I've shyed away from using tmux and Vim. For some reason, when I use tmux and Vim, if I 'copy' a snippet of text (using my mouse/cursor higlight -> right-click -> copy) it treats all of the empty space a actual "space" characters when I 'paste'. Why does it do this?

Same, I don't use tmux with vim for exactly the reasons you gave. Instead I use i3 to split screens, etc. much better imo.

exactly a tiling window manager. though i do use a multiplexer in tty if i need to work in that environment.

Re: Tmux and Vim – better together

#28
Nice article! I'm gonna introduce some of this in my configuration for sure!

I have a function in my .vimrc ( https://github.com/Morantron/dotfiles/blob/master/vimrc#L229 ) that allows me to send current vim selection to the adjacent tmux pane with vimux. This comes in very handy in REPLing sessions ( MySQL and the like ).

For copy pasting stuff ( like ids, urls, SHAs, etc ) I use https://github.com/morantron/tmux-fingers which is awesome and you should totally try it! ( )

Re: Tmux and Vim – better together

#29
post #19
post #12

Earlier quoted context omitted.

Expecting terminal programs to interact sanely with mouse gestures is somewhat futile. If I need to paste something from a vim buffer into a graphical application, I use :' !xsel -bi to copy the text. If I were doing it more often, I would probably add a keybinding to streamline the process, and solve minor annoyances like having to undo to get the copied lines back. Maybe there is a good plugin for clipboard integra…

You could use " y (and/or "+y, depending on your X clipboard setup) to yank to your clipboard. Similarly, " p paste from it.

HN garbled your "* y, but I understood anyway. Thanks!

Re: Tmux and Vim – better together

#30
All this looks really great, however I think I just can't deal with the effort of maintaining these complex editor configurations anymore.

I've been a multi-decade Vim user, until I switched to VSCode last year. It made me realize how much better the user experience can be for an editor. I had all kinds of complex vim configurations and plugins with special cases for linux vs. mac, server vs. desktop, GUI vs. terminal, all of which are a huge pain in the butt to maintain.

If there was one thing I could ask of Vim (or even emacs), it'd be a consistent high-quality default user experience.

(Ofcourse, the default experience in VSCode isn't perfect either, but it took me four lines in settings.json and four plugins (vim, go, eslint, clang) for a near-perfect experience.)

Post reply on HN