LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-17-2024, 09:51 AM   #1
minuzed
LQ Newbie
 
Registered: Apr 2024
Location: Sweden
Posts: 16

Rep: Reputation: 0
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
 
Old 04-22-2024, 11:53 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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
 
Old 04-23-2024, 02:51 AM   #3
minuzed
LQ Newbie
 
Registered: Apr 2024
Location: Sweden
Posts: 16

Original Poster
Rep: Reputation: 0
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.

Last edited by minuzed; 04-23-2024 at 06:12 AM. Reason: Tested new things
 
Old 04-23-2024, 10:51 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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
 
Old 04-24-2024, 01:57 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,897

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
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.
 
Old 04-25-2024, 01:16 AM   #6
minuzed
LQ Newbie
 
Registered: Apr 2024
Location: Sweden
Posts: 16

Original Poster
Rep: Reputation: 0
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.
 
Old 04-25-2024, 03:00 AM   #7
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,804

Rep: Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203
What yields
echo $TERM
inside and outside of Openbox?
 
Old 04-25-2024, 07:12 AM   #8
minuzed
LQ Newbie
 
Registered: Apr 2024
Location: Sweden
Posts: 16

Original Poster
Rep: Reputation: 0
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
 
Old 04-25-2024, 08:52 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,897

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
see the last post here: https://askubuntu.com/questions/9209...nside-a-script (and the link)
 
Old 04-25-2024, 01:21 PM   #10
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,804

Rep: Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203
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
 
Old 04-26-2024, 01:23 AM   #11
minuzed
LQ Newbie
 
Registered: Apr 2024
Location: Sweden
Posts: 16

Original Poster
Rep: Reputation: 0
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
 
Old 04-26-2024, 01:36 AM   #12
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,897

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
would be nice to explain all the details. Is it a console, a terminal emulator, or what? How did you enter into it?
 
Old 04-26-2024, 02:02 AM   #13
minuzed
LQ Newbie
 
Registered: Apr 2024
Location: Sweden
Posts: 16

Original Poster
Rep: Reputation: 0
I'm running vim inside a terminal emulator 'rxvt' window in Openbox.
 
Old 04-26-2024, 03:56 AM   #14
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,804

Rep: Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203
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
 
Old 04-26-2024, 04:39 AM   #15
minuzed
LQ Newbie
 
Registered: Apr 2024
Location: Sweden
Posts: 16

Original Poster
Rep: Reputation: 0
/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.

Last edited by minuzed; 04-26-2024 at 04:41 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Fedora shows 'man vim' but when execute 'vim' got "bash: vim: command not found..." ? flash_os Linux - Newbie 19 01-03-2015 11:56 PM
Switching from vim to vim -g from inside vim iDragoon Linux - Software 4 05-15-2009 11:46 AM
Editor comparison: vim VS vim-lite, Cleaning vim Ruler2112 *BSD 4 04-13-2009 04:26 PM
ls intray/ shows nothing, but sudo ls intray/ gives correct output wilsonsamm Linux - Desktop 3 06-20-2008 02:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration