LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Vim shows somewhat broken representation but the actual output to file is correct, terminal issue? (https://www.linuxquestions.org/questions/linux-software-2/vim-shows-somewhat-broken-representation-but-the-actual-output-to-file-is-correct-terminal-issue-4175736134/)

minuzed 04-17-2024 09:51 AM

Vim shows somewhat broken representation but the actual output to file is correct, terminal issue?
 
My Vim has recently started acting strange.

I open a new file in Vim as a normal user,
Code:

vim test.txt
and the bottom line shows
Code:

"test.txt" [New]  0,0-1 All
all normal. I then press 'I' (for insert mode) and the bottom line shows
Code:

-- INSERT --  0,1 All
all normal. Now, when I press the first (any) key to insert a character the cursor seems to first be jumping down a line before it inserts the character. At the bottom line (statusline) I now get 2 lines.
Code:

-- INSERT --  1,2test.txt + (~)
- VIM

If I just ignore that fact that it automatically seems to do a CR or LF and enter whatever characters/text I want and save the file, the actual output to the file seems to be correct (no extra CR or LF). From what I can think of it seems like some kind of "render" issue.

This happens when I run vim inside rxvt as well as xterm in openbox as a normal user.
It does not happen if I run 'sudo vim' or 'su - root' and then 'vim'.
It does not happen if I run it from another non-graphic tty, like tty3 as a normal user.
I'm running bash as the shell but I also tried switching to sh but the issue is the same.

Since vim seems to work fine outside of X I believe the issue is not with vim itself but rather some terminal settings that may have changed or similarly.

Any ideas that could potentially point me in the right direction is much appreciated :)

chrism01 04-22-2024 11:53 PM

It sounds like it might be referencing a different. '.vimrc' file ?
(Incidentally, a leading dot makes the file hidden to 'ls' - use 'ls -a' )

I'd at least start by checking the PATH in each case to see exactly which copy of vim it's referencing.

HTH

minuzed 04-23-2024 02:51 AM

Thanks for the quick reply.

Running echo $PATH:
As normal user inside rxvt in openbox 'echo $PATH':
Code:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
As normal user inside rxvt in openbox 'sudo echo $PATH':
Code:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
As normal user inside rxvt in openbox 'su - root' then 'echo $PATH':
Code:

/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
'echo $PATH' yield the same results running in tty3.

I searched for all .vimrc files ('find / -name "*.vimrc") in the system found only the one inside the user homedir with the following content:
Code:

set expandtab
set shiftwidth=4
set tabstop=4
set smartindent
set guifont=DejaVu\ Sans\ Mono\ 9
set hlsearch
set incsearch
set nowrap
syntax on

EDIT: I renamed .vimrc 'mv .vimrc dot.vimrc.bak' and it did no difference.

chrism01 04-23-2024 10:51 PM

Well, there can be multiple '.vimrc' and also system level 'vimrc' files - note no leading 'dot' for the system level ones.
This page shows how to find them https://stackoverflow.com/questions/...ing-vimrc-file

Also, within each env, run
Code:

which vim
to see where it's getting the prog from.
Note that one of them could easily be eg a shell script that does something funky, then calls vim on your behalf.



Basically, assume nothing(!); check all cfgs and vim 'programs' in each env.

;)


HTH

pan64 04-24-2024 01:57 AM

vim does not depend on X, it does not use any X related settings (that is gvim).
From the other hand vim uses a lot of terminal commands (like cursor movement, scroll, .....). All these commands depend on the type of the terminal. vim tries to detect it (to identify the available commands) and also you can set TERM, but anyway, if it is not set properly it may cause issues like that.
Basically, opening a terminal emulator will set this TERM variable, which should work, but can be overridden.

minuzed 04-25-2024 01:16 AM

Code:

which vim
points to the binary file /usr/bin/vim in all environments.

I also did a search for vimrc-files with
Code:

find / -name "*vimrc"
which gave me two results; /home/user/.vimrc and /usr/share/vim/vimrc. I am still not sure that the issue is in any of those files since I would guess /usr/share/vim/vimrc is loaded by all users or at least users that don't have their own .vimrc. In my case the root user doesn't have its own .vimrc so I would assume that it is using /usr/share/vim/vimrc. Also the reason I don't think there is an issue with /home/user/.vimrc is that there are no issues when running vim as the user from a ttyX outside of Openbox/X.

MadeInGermany 04-25-2024 03:00 AM

What yields
echo $TERM
inside and outside of Openbox?

minuzed 04-25-2024 07:12 AM

In rxvt inside Openbox, logged in as user:
Code:

echo $TERM = rxvt
sudo echo $TERM = rxvt
su - root, then echo $TERM = rxvt

In tty3 outside Openbox, logged in as user:
Code:

echo $TERM = linux
In tty3 outside Openbox, logged in as root:
Code:

echo $TERM = linux

pan64 04-25-2024 08:52 AM

see the last post here: https://askubuntu.com/questions/9209...nside-a-script (and the link)

MadeInGermany 04-25-2024 01:21 PM

Maybe a problem with TERM=rxvt

Try to start vim with another TERM environment.
Command line (in a rxvt):
Code:

env TERM=linux vim filename
And another one:
Code:

env TERM=xterm vim filename

minuzed 04-26-2024 01:23 AM

After reading pan64's link and trying out
Code:

env TERM=linux vim test.txt
I've made some progress.
When running
Code:

env TERM=linux vim test.txt
the issue seems to be gone. So why is it working when running as root while TERM=rxvt but not as the user when TERM=rxvt? Are there some settings that are being applied with 'rxvt' on a per user basis somewhere that might have gone rogue?
I feel like we're going in the right direction :)

pan64 04-26-2024 01:36 AM

would be nice to explain all the details. Is it a console, a terminal emulator, or what? How did you enter into it?

minuzed 04-26-2024 02:02 AM

I'm running vim inside a terminal emulator 'rxvt' window in Openbox.

MadeInGermany 04-26-2024 03:56 AM

I guess there is something wrong in your /usr/share/terminfo/r/rxvt (binary terminfo file compiled by tic).
(Well, another reason could be a bad rxvt entry in the legacy /etc/termcap (text file).)

You can try to set TERM to other rxvt variants in /usr/share/terminfo/r/

Command to list all terminal types along with a short description:
Code:

toe /usr/share/terminfo

minuzed 04-26-2024 04:39 AM

/usr/share/terminfo/r/rxvt does not exist but rxvt-unicode and rxvt-unicode-256color does and they are the only files in that directory.
/etc/termcap does not exist on my system. Unfortunatly 'toe' does not exist either since this is a pretty minimalistic system.
Inside /usr/share/terminfo there only exist the directory 'r' which contains the two binaries mentioned above.

Running
Code:

env TERM=rxvt-unicode vim test.txt
or
Code:

env TERM=rxvt-unicode-256color vim test.txt
both yields vim with the issue.


All times are GMT -5. The time now is 05:35 AM.