LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Striking End key within vim prints 'F' (GUI terminal). (https://www.linuxquestions.org/questions/slackware-14/striking-end-key-within-vim-prints-f-gui-terminal-4175522949/)

stf92 10-21-2014 03:21 PM

Striking End key within vim prints 'F' (GUI terminal).
 
Slackware 14.0-32

Hi: from within a virtual console (the consoles given the user just after booting slackware), if I run vim and press the End key the result is the same as pressing $ in command mode (cursor goes to end of line). The same sequence of events started from a GUI terminal gets an 'F' printed. I tried this escape sequence in ~/.inputrc:
Code:

"\e[4~": end-of-line          # End key
but the shell does not even read that file when I start a terminal in the GUI. Any known solution, assuming this is a problem? Does vim read the same init files when running from the GUI as when running from a virtual console?

T3slider 10-21-2014 03:38 PM

If you add this to .bashrc it should read .inputrc:
Code:

export INPUTRC=~/.inputrc
I believe the problem is in the terminfo files, which may be non-existent or poorly written for your particular terminal emulator (but don't quote me on that).

stf92 10-21-2014 03:58 PM

Still printing 'F'. If I say bash does not read ~/.inputrc it's only because writing junk in it I don't get an error when starting a terminal from the GUI, but that's not correct, as opening a virtual console does not give an error either.

T3slider 10-21-2014 04:23 PM

Code:

$ echo $INTUPRC
in the terminal should tell you if the variable was properly exported. If you are using a login shell in X (for shame) then it won't be sourced unless you have something like this in .bash_profile:
Code:

if [ -e ~/.bashrc ]; then
    . .bashrc
fi

If the variable *is* properly exported when you open a new terminal, and it still doesn't work, then I don't know what else to say.

[edit] Actually that line should already be in /etc/inputrc which bash should automatically source...see this thread for more information, and there is another linked thread there. I haven't read it all.

[edit2] If you're getting F printed then the line you want is this one I think:
Code:

"\e[F": end-of-line
...or maybe
Code:

"\eOF": end-of-line
or just
Code:

"\eF": end-of-line
??

stf92 10-21-2014 04:36 PM

I wrote a /usr/local/bin/bw.sh:

AUX=$TERM
TERM=linux-m
vim $1
TERM=$AUX

and use alias vim=/usr/local/bin/bw.sh in /etc/profile, so that vim runs with TERM=linux-m (m stands for monochrome) in the GUI. So the stated problem vanishes if I start vim as
Code:

$ \vim
which undoes the alias when running from the GUI. Until I find a more straightforward solution I'll keep using this.

stf92 10-21-2014 04:44 PM

Sorry, I didn't read your post. TERM is set to '/etc/inputrc', where I have the escape sequences, to no avail. But I wrote above what was happening.

keefaz 10-21-2014 06:22 PM

maybe a weird key mapping from X?
What value do you have for keycode and keysym when running xev in gui terminal and pressing the end key?

stf92 10-21-2014 07:33 PM

115, 0xff57. But the keyboard mapping works at a low level, and the key is trapped by higher level software. Please remember TERM=linux-m is the immediate cause of the problem here.

keefaz 10-21-2014 08:11 PM

Is it the same with any X terminal, xterm, rxvt, konsole...?

stf92 10-21-2014 08:36 PM

xterm and konsole have the same problem as described. rxvt works nicely in this respect.

keefaz 10-21-2014 08:39 PM

Maybe $TERM is set differently in rxvt? try echo $TERM in those x terminals to see

ljb643 10-21-2014 08:42 PM

Quote:

Originally Posted by stf92 (Post 5257353)
I wrote a /usr/local/bin/bw.sh:

AUX=$TERM
TERM=linux-m
vim $1
TERM=$AUX

and use alias vim=/usr/local/bin/bw.sh in /etc/profile, so that vim runs with TERM=linux-m (m stands for monochrome) in the GUI. So the stated problem vanishes if I start vim as
Code:

$ \vim
which undoes the alias when running from the GUI. Until I find a more straightforward solution I'll keep using this.

You can't do that. The linux-m terminal type is not compatible with X terminals - it is only for the virtual consoles. The escape sequences are different. For the END key, linux-m tells vim to expect Esc-[4~, but the X terminal is actually sending Esc-OF (that last F is what you are seeing when vim and the libraries don't understand the sequence).

phi11ip 10-22-2014 05:26 AM

Vim doesn't use ~/.inputrc or /etc/inputrc as its initiation file it uses ~/.vimrc. The END key works ok for me in vim (console and gui). Try putting this line in your ~/.vimrc file:-
Code:

nnoremap <END> $

stf92 10-22-2014 12:17 PM

Quote:

Originally Posted by keefaz (Post 5257467)
Maybe $TERM is set differently in rxvt? try echo $TERM in those x terminals to see

No, TERM= xterm in rxvt as well as in Terminal 0.4.8 (/usr/bin/Terminal, from the Xfce suite), which is the terminal I use on the GUI.

Trying to see if X is running by script, I wrote
Code:

#!/bin/sh

#### WATCH THE ARGUMENT TO ps IS asdf, NON EXISTING PROCESS.
VAR1="$( /bin/ps -C asdf )"    #VAR1 gets the text output from /bin/ps
echo $VAR1
echo END

# echo outputs to stdout, grep takes input from stdout. Last command
# in the pipe gives ? its exit code.
echo $VAR1 | grep X         

# print grep exit code, 0= 'X' found, 1= 'X' not found, else= error.
echo "exit code= $?"

# So far so well. As asdf is not running, I expect the if echoing
# 'Xnotrunning'. But it'll output 'Xisrunning'! However the printed
# exit code was 1.
if [ $? -eq 0 ]
then
    echo Xisrunning
else
    echo Xnotrunning
fi
exit

But there is something with the [ xxxx -eq xxxx ] that won't work, as the code above will show. May I ask why

keefaz 10-22-2014 12:24 PM

You're testing previous command which is echo "exit code= $?"


All times are GMT -5. The time now is 04:40 AM.