LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-06-2013, 04:54 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
The Home and End keys in vim under the GUI terminals.


Hi:
When in a text console, in vim, pressing the Home key in insert mode has the same effect it has always had using vim in a text console after a slackware normal installation: it brings the cursor to the first column in the line (not the same as '^' in command mode, which takes the cursor to the first non blank character in the current line). When in a GUI terminal, however, and in Slackware 14.0, pressing the Home key causes a capital H to be printed. The same can be said about the End key: it prints a capital F.

It seems that vim, under the GUI (desktop environment= Xfce 4.0), does not read the same initialization files than when run in a console. The aim is that those two keys behave in the same way as in the consoles. But I do not have a clear idea about the difference between running vim in a GUI terminal and running it in a console. Any suggestion would be welcome.





Kernel 3.2.29, Slackware 14.0
 
Old 12-06-2013, 05:28 PM   #2
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 687
Blog Entries: 1

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
I have never used home/end but for me, the keys work the same under vim inside rxvt, xterm and the console. What terminal emulator are you using ? I would have to guess that is either catching the keys or maybe it is your $TERM setting used by the emulator.

TERM for me is:
rxvt/xterm = xterm
console = linux
 
Old 12-06-2013, 05:56 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Unfortunately, when I evoke a program from within the GUI, I do it by selecting an item within a menu and do not know how to ask the program "what is your full path"? But Help>About says: "Terminal 0.4.8, Xfce terminal emulator".

TERM when in a text console is set to 'linux'. I mean
Code:
$ echo $TERM
linux
$
In the GUI TERM has exactly the same value. I mean, in a terminal I type 'echo $TERM' and get 'linux'. Now, in the terminal window (the GUI) I do Edit>Preferences>Advanced and get

$TERM setting: xterm

Should I write another value for TERM in the dialog box?
 
Old 12-06-2013, 07:54 PM   #4
ljb643
Member
 
Registered: Nov 2003
Posts: 526

Rep: Reputation: Disabled
Yes, the TERM setting in your shell running inside the GUI (xfce Terminal) is wrong. It should be "xterm", not "linux"; if it is "linux" some keys like HOME and END will not work. Since your preferences in the terminal are correct (by the way, that setting seems to have been removed from the Terminal with Slackware 14.1), I suspect something else is overriding it. Check the shell startup files such as /etc/profile ~/.profile ~/.bashrc and any pointed to by $ENV. (There may be others.) My guess is that somewhere in there you have it setting TERM=linux.
 
1 members found this post helpful.
Old 12-06-2013, 08:26 PM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
I simply did this:
Code:
semoi@server:~$ echo $TERM
linux
semoi@server:~$ TERM=xterm
semoi@server:~$
and now home/end behave as they should when vim is run from a graphics terminal. The behavior in the text consoles was unchanged: it is still the correct one. Now, in /etc/profile I have:
Code:
# I had problems with the backspace key using 'eval tset' instead of 'TERM=',
# but you might want to try it anyway instead of the section below it.  I
# think with the right /etc/termcap it would work.
# eval `tset -sQ "$TERM"`

# Set TERM to linux for unknown type or unset variable:
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux
fi
The line 'TERM=linux' gets executed, it seems, because that is the value of TERM when booting is over. However I have my doubts about subtituting 'TERM=xterm' in that place. Most of the times I work only on the consoles (/dev/tty1 through /dev/tty6) and the name xterm seems to have to do with X. And what has X to do when I'm only working in the text console?

On the other hand, the fact that TERM is set to 'linux' in my system, never induced the strange behavior of the home/end keys described above while running vim in a text console. Plus, when I am at a GUI terminal, those keys work perfectly well when I type commands. It is only when I enter vim, and still being in the GUI that those keys behave strangely.

Note: I used several different terms to refer to one and the same thing, namely the virtual terminals (aka virtual consoles) /etc/tty1 through /etc/tty6. So I have used /etc/ttyN = virtual terminal = console = text console in the text above.

Last edited by stf92; 12-06-2013 at 08:32 PM.
 
Old 12-07-2013, 01:11 AM   #6
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
You can set the behaviour in ~/.inputrc:

Code:
 # kvt:
"\e[H":beginning-of-line
"\e[F":end-of-line
 # rxvt and konsole (i.e. the KDE-app...)
"\e[7~":beginning-of-line
"\e[8~":end-of-line
 # for linux console
 "\e[1~": beginning-of-line
 "\e[4~": end-of-line
I don't know all the escape codes for ones like xterm etc. but running 'cat' and then pressing home and end should give them.
 
1 members found this post helpful.
Old 12-07-2013, 09:36 AM   #7
ljb643
Member
 
Registered: Nov 2003
Posts: 526

Rep: Reputation: Disabled
Setting TERM in /etc/profile is Slackware's fallback code, but it should neither fix nor break anything. When you log in to a console, the TERM is set to 'linux' from the line in /etc/inittab which runs agetty on that terminal. TERM=linux is the correct setting for the console.

Whether you start your X session using startx, or your system boots to runlevel 4 and runs xdm, the TERM setting should be irrelevant once your session starts and you open a terminal window. The Xfce Terminal program should set TERM=xterm and that should stick within that window. Since that isn't happening for you, either it isn't being set by Xfce Terminal (check Edit menu, Preferences, Advanced tab, under Compatibility for $TERM setting), or some other shell startup script that runs after Terminal starts the shell is changing it to something else. The code you copied above from /etc/profile isn't doing it (since it only changes TERM if it is empty or 'unknown').
 
1 members found this post helpful.
Old 12-07-2013, 06:03 PM   #8
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by ljb643 View Post
Setting TERM in /etc/profile is Slackware's fallback code, but it should neither fix nor break anything. When you log in to a console, the TERM is set to 'linux' from the line in /etc/inittab which runs agetty on that terminal. TERM=linux is the correct setting for the console.
Alright. You are speaking about
Code:
# These are the standard console login getties in multiuser mode:
c1:12345:respawn:/sbin/agetty --noclear 38400 tty1 linux
c2:12345:respawn:/sbin/agetty 38400 tty2 linux
c3:12345:respawn:/sbin/agetty 38400 tty3 linux
c4:12345:respawn:/sbin/agetty 38400 tty4 linux
c5:12345:respawn:/sbin/agetty 38400 tty5 linux
c6:12345:respawn:/sbin/agetty 38400 tty6 linux
I discovered where the problem is, and it is my fault. In /etc/profile, I was setting TERM to 'linux-m' (m for monochromatic) near the end of that file. I should have just replaced the code
Code:
# Set TERM to linux for unknown type or unset variable:
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux
fi
in /etc/profile by
Code:
# Set TERM to linux for unknown type or unset variable:
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux-m
fi
This file, /etc/profile is then the script that got executed after Terminal started the shell and changed the TERM setting from 'xterm' to 'linux-m' (by the way I'd like to know the full pathname of this Terminal program). But only because of the modification made by me.

But setting TERM=linux-m has an upsetting side effect (this time speaking just about the console): it sets horizontal scroll mode. I do not know if the horizontal-scroll-mode readline variable gets set to On, but everything happens as if it were set to On when TERM == linux-m. I wrote a program to query the value of that variable, using the readline library rl_variable_dumper function, but there seems to be some trouble with this library requiring some special workarounds.

So, what I'm doing just now is to set TERM manually either to linux or to linux-m according to what I need at the moment. If I am typing many commands at the shell prompt then I set it to 'linux', thus avoiding the horizontal scroll thing.

EDIT: The lines
Code:
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux-m
fi
won't do anything because TERM is already set in /etc/inittab.

Last edited by stf92; 12-07-2013 at 06:27 PM.
 
Old 12-07-2013, 07:24 PM   #9
ljb643
Member
 
Registered: Nov 2003
Posts: 526

Rep: Reputation: Disabled
Quote:
Originally Posted by stf92 View Post
... (by the way I'd like to know the full pathname of this Terminal program).
At Slackware 14.0 it is /usr/bin/Terminal (with a link there from /usr/bin/terminal).
At Slackware 14.1 it is /usr/bin/xfce4-terminal

(I'm not clear: is this problem with Home and End keys not working in Vim in a terminal window fixed?)

Regarding the other problem, horizontal scrolling, I tried it myself and you are right and I don't know why. (This is not vim, but things like bash that use readline.) The linux and linux-m terminfo settings are identical except for color, so it isn't coming from there. I suppose you could turn that off by putting "horizontal-scroll-mode Off" in ~/.inputrc but I would sure like to know why it changes.

(Edit: It doesn't work, horizontal scroll is still on with linux-m.)

Last edited by ljb643; 12-07-2013 at 07:32 PM. Reason: Fix horizontal-scroll-mode
 
1 members found this post helpful.
Old 12-07-2013, 07:39 PM   #10
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by ljb643 View Post
(I'm not clear: is this problem with Home and End keys not working in Vim in a terminal window fixed?)
Yes it is, and I'm marking the thread SOLVED as that was its subject. You gave me the key to solve it in your post, for which I thank you.

Horizontal scrolling: I put 'set horizontal-scroll-mode=Off in /etc/inputrc, INPUTRC being equal to '/etc/inputrc' but that did not solve the problem. Anyways, Off is the default value for that readline variable. Why changing TERM from 'linux' to 'linux-m' should set horizontal scrolling seems to me one of the great mysteries of nature. Perhaps this could be pointed out as a bug to the relevant people. But they would ask me to install the latest versions of the relevant software. I could, anyways make room in the disk to install the newest software and see if the problem persists. At present I have Slacware 14.0 x86_64 installed asis.

Last edited by stf92; 12-07-2013 at 07:45 PM.
 
  


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
using home and end keys via ssh putty section31 Linux - Software 3 12-01-2011 09:42 AM
[SOLVED] Home and End keys in a terminal Josh000 Slackware 11 04-24-2010 03:44 PM
Home / End keys in aterm Vgui Linux - General 4 08-11-2005 12:59 PM
Home/End keys don't work Abdul Linux - Software 2 07-25-2005 08:48 PM
Home and End keys in RXVT kevmccor Slackware 3 12-16-2004 04:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:36 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