1

Ubuntu: 18.04 bionic
tmux: version 2.6
VIM: Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 )
Included patches: 1-1453
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Huge version with GTK3 GUI.
My .tmux.conf file was initially empty, but then I edited by basically copying the Linux part of this answer from UnixSE. The problem below occurred both before and after I edited that conf file.

There is a website I always use (I can give out the name of the website if others believe it's relevant), and copy text from. When I'm using Vim in bash without tmux, I can paste the text to Vim without problems and it looks like this:

 Defensa de la persona humana

 Artículo  1.- La defensa de la persona humana y el respeto de su dignidad son el fin supremo de la sociedad y del Estado.

 JURISPRUDENCIA DE LA CORTE SUPREMA DE JUSTICIA

 Derechos fundamentales de la persona

However, when I'm inside tmux, the indentation 'breaks' and I get something like this:

 Defensa de la persona humana

    Artículo  1.- La defensa de la persona humana y el respeto de su dignidad son el fin supremo de la sociedad y del Estado.

       JURISPRUDENCIA DE LA CORTE SUPREMA DE JUSTICIA

          Derechos fundamentales de la persona

That has never happened when I paste the text on Vim inside bash (without tmux). And, in case it matters, the way I usually copy and paste is by selecting the text on my web browser, then pressing Ctrl+C , then going to Vim, enter Insert Mode, and finally press Ctrl+Shift+V .

Edit: This problem happens only with that specific website. However, it's not fully a problem from the website because, as explained above, the pasting works totally fine outside tmux.

How can I make Vim inside tmux paste my text the way it is in the block in the top?
What do I need to fix?

  • try using :set paste before insertion maybe ; I use tmux but I never had a similar case. – francois P Mar 5 at 19:34
  • @francoisP , that command fixed the problem, thank you! I also found some other observations which I'll explain in my next edit. Please consider writing an answer to this post; I'll most probably accept it after 24 hours of waiting. – evaristegd Mar 5 at 19:54
  • @francoisP , by the way, do you think I can see your .tmux.conf file? If not, what would you recommend? – evaristegd Mar 5 at 19:56
  • 1
    @francoisP , your answer says 'past' instead of 'paste'. – evaristegd Mar 5 at 20:32
0

So using :set paste first can resolv the issue.

as you asked here is my tmuxrc but it is very short :

:~$ cat ~/.tmuxrc
set -g status-utf8 on
:~$

So I don't think it is special

| improve this answer | |
  • 1
    Reminder that one should unset it afterwards – D. Ben Knoble Mar 6 at 13:54
0

I still do not understand exactly what is causing the problem; however, I found two ways to solve it after reading this related post.
One is adding the following line to your ~/.tmux.conf file:

set -g default-terminal "xterm"

The other way is to add the following line to that same file:

set -g default-terminal "xterm-256color"

Those solutions notwithstanding, the solution from Francois's answer seems simpler.

| improve this answer | |
  • 1
    For anyone reading this answer, setting 'default-terminal' to anything other than "screen", "tmux" or a derivative is wrong; it will lead to other issues. Before setting any option, read the only source of reliable information about tmux, which is not this site, not stackoverflow, nor some blog post, but the man page. – user938271 Mar 6 at 7:06
  • @user938271 , thank you for bringing this to my attention. I will review your sources. – evaristegd Mar 6 at 14:48
  • 1. The main difference is that it assigns a correct value; i.e. screen-256color is ok, xterm or xterm-256color is not. 2. By writing xterm or xterm-256color, you're making Tmux initialize $TERM with a value which tells all the applications (not just Vim) that they're talking to the xterm terminal, which is a lie; they are not talking to xterm directly (in fact the outer terminal may not even be xterm); they are talking to the Tmux terminal. They will now query a wrong entry in the terminfo database when they'll need to use a terminal capability. – user938271 May 23 at 8:52
  • 3. Your issue is probably due to Vim which doesn't enable the bracketed paste mode. If that's the case, then the best solution is not to meddle with Tmux but with Vim, and to configure terminal options as explained at :h xterm-bracketed-paste. 4. The reason why your line "fixes" the issue is probably because when Vim thinks it's talking to xterm, it automatically configures the terminal options for you. But a good fix should not introduce regressions, which set -g default-terminal "xterm" does. – user938271 May 23 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.