0

I am using something right now that has ssh login for two separate linux terminals in order to use vim to code. The first ssh login is my main one and for some reason, if I open and code a program using vim, I am able to use by arrow keys to navigate while in Insert Mode. When I use the arrow keys, I never have to hit Esc, I can simply press up/down/left/right on my arrow keys and the cursor moves perfectly while I am still in insert mode. For some reason, the cursor moves much faster holding down one of the arrow keys compared to holding down h/j/k/l (not sure why this occurs).

My issue is that I have been unable to recreate this feature/functionality on my secondary linux ssh login (which is nearly identical to the main linux ssh I use). I feel there must be a command I can input while in command mode (ex. :use arrow keys) or something else I can do to make this permanent.

I know it is heavily disliked to use arrow keys to navigate vim, but I am currently desperate to find an answer for specific reasons. Most articles and threads I've found show keyboard shortcuts that mimic similar behavior but I am specifically trying to recreate the usage of regular arrow keys while in Insert Mode. Anyone know if this is possible or why this is occurring on one linux ssh terminal and not the other? I am on an M1 MacBook Air for reference.

Edit: Main Linux Terminal

Doing :version on the main linux terminal results in:

:version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 01 2022 09:16:32)
Included patches: 1-2269, 3612, 3625, 3669, 3741
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +clipboard         +dnd               +gettext           +localmap          +mouse_urxvt       +profile           +statusline        +timers            +windows
+arabic            +cmdline_compl     -ebcdic            -hangul_input      +lua               +mouse_xterm       -python            -sun_workshop      +title             +writebackup
+autocmd           +cmdline_hist      +emacs_tags        +iconv             +menu              +multi_byte        +python3           +syntax            +toolbar           +X11
+autochdir         +cmdline_info      +eval              +insert_expand     +mksession         +multi_lang        +quickfix          +tag_binary        +user_commands     -xfontset
-autoservername    +comments          +ex_extra          +job               +modify_fname      -mzscheme          +reltime           -tag_old_static    +vartabs           +xim
+balloon_eval      +conceal           +extra_search      +jumplist          +mouse             +netbeans_intg     +rightleft         -tag_any_white     +vertsplit         +xpm
+balloon_eval_term +cryptv            -farsi             +keymap            +mouseshape        +num64             -ruby              +tcl               +virtualedit       +xsmp_interact
+browse            +cscope            +file_in_path      +lambda            +mouse_dec         +packages          +scrollbind        +termguicolors     +visual            +xterm_clipboard
++builtin_terms    +cursorbind        +find_in_path      +langmap           +mouse_gpm         +path_extra        +signs             +terminal          +visualextra       -xterm_save
+byte_offset       +cursorshape       +float             +libcall           -mouse_jsbterm     +perl              +smartindent       +terminfo          +viminfo
+channel           +dialog_con_gui    +folding           +linebreak         +mouse_netterm     +persistent_undo   +sound             +termresponse      +vreplace
+cindent           +diff              -footer            +lispindent        +mouse_sgr         +postscript        +spell             +textobjects       +wildignore
+clientserver      +digraphs          +fork()            +listcmds          -mouse_sysmouse    +printer           +startuptime       +textprop          +wildmenu
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu
/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cair
o -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib
/x86_64-linux-gnu/glib-2.0/include -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-9EpYYi/vim-8.1.2269=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTI
FY_SOURCE=1
Linking: gcc   -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0
-lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lcanberra -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L
/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.30/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm -L/usr/lib/
x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm

Doing :verbose set compatible? results in compatible

Secondary Linux Terminal

Doing :version on the secondary linux terminal results in:

:version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 01 2022 09:16:32)
Included patches: 1-2269, 3612, 3625, 3669, 3741
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +clipboard         +dnd               +gettext           +localmap          +mouse_urxvt       +profile           +statusline        +timers            +windows
+arabic            +cmdline_compl     -ebcdic            -hangul_input      +lua               +mouse_xterm       -python            -sun_workshop      +title             +writebackup
+autocmd           +cmdline_hist      +emacs_tags        +iconv             +menu              +multi_byte        +python3           +syntax            +toolbar           +X11
+autochdir         +cmdline_info      +eval              +insert_expand     +mksession         +multi_lang        +quickfix          +tag_binary        +user_commands     -xfontset
-autoservername    +comments          +ex_extra          +job               +modify_fname      -mzscheme          +reltime           -tag_old_static    +vartabs           +xim
+balloon_eval      +conceal           +extra_search      +jumplist          +mouse             +netbeans_intg     +rightleft         -tag_any_white     +vertsplit         +xpm
+balloon_eval_term +cryptv            -farsi             +keymap            +mouseshape        +num64             -ruby              +tcl               +virtualedit       +xsmp_interact
+browse            +cscope            +file_in_path      +lambda            +mouse_dec         +packages          +scrollbind        +termguicolors     +visual            +xterm_clipboard
++builtin_terms    +cursorbind        +find_in_path      +langmap           +mouse_gpm         +path_extra        +signs             +terminal          +visualextra       -xterm_save
+byte_offset       +cursorshape       +float             +libcall           -mouse_jsbterm     +perl              +smartindent       +terminfo          +viminfo
+channel           +dialog_con_gui    +folding           +linebreak         +mouse_netterm     +persistent_undo   +sound             +termresponse      +vreplace
+cindent           +diff              -footer            +lispindent        +mouse_sgr         +postscript        +spell             +textobjects       +wildignore
+clientserver      +digraphs          +fork()            +listcmds          -mouse_sysmouse    +printer           +startuptime       +textprop          +wildmenu
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu
/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cair
o -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib
/x86_64-linux-gnu/glib-2.0/include -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-9EpYYi/vim-8.1.2269=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTI
FY_SOURCE=1
Linking: gcc   -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0
-lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lcanberra -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L
/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.30/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm -L/usr/lib/
x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm

Doing :verbose set compatible? results in nocompatible Last set from /usr/share/vim/vim81/debian.vim line 3

mpp
  • 109
  • What do :version and :verbose set compatible? report for each of these Vims? – muru Jul 21 '22 at 02:25
  • What is your terminal emulation for one session and for the other session? Different terminal emulations use different codes for arrow keys. – Philippos Jul 21 '22 at 05:09
  • @muru I edited my post to include the outputs for both commands. Is there anything that stands out? I am not too familiar with linux/vim and the settings for them. – mpp Jul 22 '22 at 07:50
  • @Philippos How can I check my terminal emulation? – mpp Jul 22 '22 at 07:50
  • echo $TERM. Maybe https://unix.stackexchange.com/questions/29907/how-to-get-vim-to-work-with-tmux-properly/34723#34723 is related. – Philippos Jul 22 '22 at 07:59
  • @muru it has been fixed – mpp Jul 22 '22 at 08:03
  • @Philippos for the main linux terminal, output is: xterm-256color. For the secondary linux terminal, output is: xterm-256color. I read through the thread you linked but I think since the output is the same on both terminals it may not be the correct solution, but I'm not too sure. Any advice? – mpp Jul 22 '22 at 08:06
  • @mpp are you sure the the one in which the arrow keys work has compatible set? I'd expect it to be the other way around (compatible - arrow keys don't work in insert mode; nocompatible - arrow keys do work) – muru Jul 22 '22 at 08:13
  • @muru I just tried again and now the output is different. Main terminal: nocompatible Last set from /usr/share/vim/vim81/debian.vim line 3. Secondary terminal: nocompatible Last set from /usr/share/vim/vim81/debian.vim line 3 however, the secondary terminal still won't allow me to use arrow keys – mpp Jul 22 '22 at 08:22

0 Answers0