Linux vi arrow keys broken in insert mode - linux

My arrow keys don't work in vi in insert mode at home, they just each insert a newline and a capital letter, like 'A'. Is there a way to fix that?

I presume you're using vim as this is tagged as Linux. Try:
:set nocompatible
(You may want to configure your .vimrc with this by adding this command to it. Create a new .vimrc file if not already present in your home directory, run echo $HOME to check home directory path.)

Ubuntu ships default with vim-tiny, which doesn't have all the bells and whistles that vim has.
Do a quick sudo apt-get install vim to get all the juicy features that everyone's talking about.

:set term=builtin_ansi
fixed it for me. You can either paste that into vim while in escape mode, (bleep mode) or add it to the end of ~/.vimrc without the leading ":"

vi does not support arrow keys in insert mode. Use vim. Although your vi may just be a link to vim, it may be configured to behave like the "original" vi and thus disables the arrow keys. Just invoke vim directly.

Yet another variation: this problem appeared for me after some .vimrc changes. A concerted search eventually revealed that my clever re-mapping of ESC in normal mode was not a good idea. Removing it solved the problem:
" this is NOT something you want in .vimrc:
" In normal mode, hitting Esc turns off search highlights:
nmap <ESC> :nohl<CR> " Do NOT add this to .vimrc

The only thing that worked for me was ":set term=ansi"

I had same issue with arrow keys, but when I used did that set nocp or nocompatible then my backspace didn't work correctly
for some reason when I installed vim with
sudo apt-get install vim, vi didn't had any issues with arrows or backspace anymore

In WSL integrated terminal on VS Code, update the package and install the full package of vim worked for me.
sudo apt-get update
sudo apt-get install vim
However, to make the arrow key works when I use conemu I have to add :set term=builtin_ansi on ~/.vimrc
echo ':set term=builtin_ansi' >> ~/.vimrc

I just had an issue with arrow keys after switching over to use git in .vim.
I have installed this repo - https://github.com/sunaku/.vim
and after digging around for an hour, I found that AutoClose plugin
(which didn't like anyway) broke the arrow keys.
The plugin docs suggest that one should set set ttimeoutlen=100, but
that didn't work for me! (using urxvt+screen or urxvt, and even xterm)
So I removed the plugin at the end.

You might also want to try 'noesckeys'

I had the same issue while using vim inside Windows 8.1 with Cygwin.
Solution worked for me is, just run the following command in your Cygwin terminal:
cp vimrc_example.vim ~/.vimrc

In the command line write this:
EXINIT="set nocompatible"; export EXINIT

Related

E349: No identifier Under Cursor

Every time I switch back to vim window, it shows the list, if current cursor on an empty line, it shows error: E349: No identifier Under Cursor.
The only workaround for this problem that I've discovered so far was to run tmux and then run vim inside one of tmux's panes.
According to https://unix.stackexchange.com/a/480138 ,
it is the FocusIn/FocusOut mode that can be disabled with:
echo -ne '\e[?1004l'
I encountered this problem when I would lose an ssh connection, so tmux on the remote server that enabled FocusIn/FocusOut mode would not be able to disable it. If I opened a vim on my local machine, vim would receive those events. If the FocusIn/FocusOut mode is not the default for your terminal, you can also disable it with:
reset
That list looks a lot like the output of :ilist! Plugin or [I with the cursor on Plugin or ]I with the cursor on the first Plugin. See if you don't have that somewhere in your vimrc (that you should append to your question, by the way).
The error message is likely caused by :help gd or :help gD.
It caused by the wincent/terminus plugin.
Fixed
Append let g:TerminusFocusReporting=0 to .vimrc
Alt-tabbing into Terminal sends a ^] command to VIM. To ignore that command, put
nnoremap ^] <Nop>
in your .vimrc file
I had to fix by removing the line set ttymouse= from my .vimrc.
You may need to set ttymouse to an appropriate value, see :h ttymouse.
I appeared in the 3.12 version of iterm2, and now it disappears after upgrading to 3.15

latex-suite F9 completion key works in gvim but not in vim

I am setting up a latex-suite environment for my vim. I discovered that the F9 key that is used to complete references (be them \ref{ or \cite{) only works when I edit the file in gvim (showing that the setup is correct) but not in vim (konsole or xterm terminals tested). Has anybody experienced such a situation? How could one fix this problem ? Thanks a lot for your help.
~~~
System:
VIM - Vi IMproved 7.4 in a Debian GNU/Linux box
For me the problem was in the vimrc. I had set paste in there and after I removed it, F9 would work again.
If you want to find out, if it is related to the vimrc, you can create another one and use that one with vim -u ~/.vimrc_latex

vim system register * and + not working

:echo has('clipboard') returns 1, but whenever I execute "+yy" or "*yy" nothing seems to be in those registers. If I use regular yy to copy another line of text, then try to paste from the register using CONTROL+V nothing happens. If I try "+p vim pastes the line of text I copied using the regular yy command.
What's going on here? I'm on FreeBSD by the way.
Your vim version may not be compiled with X11 clipboard integration.
In vim run the :version command and look for xterm_clipboard in the output. It will be prefixed with a + (supported) or - (unsupported) sign.
What worked for me in Ubuntu 20.04 and Vim 8.1.2269
sudo apt install vim-gtk3
Explanation
This package adds support for the x_term_clipboard in vim if not present already.
For more info: Click Here, #blankblank's answer.
Another thing that could be going on is your DISPLAY environment variable is not being set correctly. This could happen sometimes if you're running vim from tmux or screen.
Try opening a new terminal, running echo $DISPLAY, and then from the terminal running vim, leave vim, execute export DISPLAY=:0 (but replace :0 with the output from your other terminal), and then re-enter vim and see if clipboard works by doing "+p.
If you have copy something to clipboard and paste that in vim, you can use "+p.
+ is a quoteplus, which means CLIPBOARD documented X selection. :help quoteplus for more information.
If you want to copy something in vim to clipboard and paste the content in the other place by Ctrl+v, you can do "+yy, this will copy the current line to clipboard.
more information about vim register:
:help registers
:help quotestar
I also met this problem.
My case is that DISPLAY is not set properly in tmux.
And I found a script to automatically update tmux DISPLAY.
My problem was my input source English (US, intl., with dead keys), in addition to vim not being compiled with x-clipboard.
I don't face the same issue on windows, but on Ubuntu 20.04 I have to press "<space>+y with this input source.
Edit:
Seems I can fix this by switching the input source to English (Intl. with AltGr dead keys)

vim "syntax on" does not work

Here is my .vimrc
1 syntax on
2 set ts=4
3 set number
4 set smartindent
5 set shiftwidth=4
However, I tried to edit HelloWorld.java and HelloWorld.c. Both have pure regular black font. No any highlighting!
I also tried :syntax on after the vim is open, but no luck.
\>vim -version
VIM - Vi IMproved 7.3 (2010 Aug 15)
\>cat /etc/*-release
openSUSE 11.4 (x86_64)
VERSION = 11.4
CODENAME = Celadon
When you edit the file, are you using
vim filename
This can matter. In some server configurations, if you do vi filename you get vim, but it's a very stripped down version of vim that is very much like the original vi (which does not, among other things, do syntax coloring). On a system configured in this way, if you instead type vim filename, you get the full featured vim.
I just worked through this with a person who was on a server that had the vim-minimal package installed as well as another vim package. I suspect (but did not verify that) the vim-minimal package installed its executable as /bin/vi.
The difference was very clear when you looked at the actual files (i.e. ls -l /bin/vi vs ls -l /usr/bin/vim)--one was about ten times the size. Both of them were actually vim, same version number and everything, but the /bin/vi one was compiled with very few features enabled.
To make it even more confusing:
vi existing.pl
opened the .pl file, gave no syntax coloring
vi [enter]
gave the vim splash screen, and from there
:e existing.pl
opened the file with syntax coloring on.
A comment from Jan Wilamowski suggests checking by doing:
vi --version
If that shows that the syntax feature was not compiled in, try
vim --version
and see if it is compiled in there.
You'll need to install the vim-data package on openSUSE for vim syntax colouring to work.
Sounds strange, I know that this is not pulled in by default with the vim package but AFAIK it's for people who want to create tiny base installs.
Package vim-data contains the runtime files.
Also make sure your remote environment has an appropriate TERM variable set TERM=screen-256color, TERM=xterm, TERM=xterm-256color should all work just fine with ssh and ssh with screen/tmux.
If all above have been done and you see some underlines and bold instead of actual colors... this might work for you:
export TERM=xterm-color
in your .vimrc, I don't see filetype setting. you could try to add:
filetype plugin indent on
to your vimrc.
if you don't have set nocp, add this line too.
if you read :h filetype
:filetype on
Each time a new or existing file is edited, Vim will try to recognize the type
of the file and set the 'filetype' option. This will trigger the FileType
event, which can be used to set the syntax highlighting, set options, etc.
For some strange reason on MacOS, 'syntax on' must be the first line in your .vimrc file. The line appears to be ignored if placed elsewhere in the file.
One item not mentioned is :set syntax=<type>, e.g. :set syntax=markdown.
This has been successful in instances where other techniques above were not.

Vim commands :Explore :Sexplore :Hexplore doesn't work in cygwin

3.3 in cywing 2.721, the installation was made using cywing, every thing works but when I try to use the following command.
:Explore
vim said E492: Not an editor command
also neither :Sexplore or :Hexplore works.
is there any way to activate this functionality?
This is in machine with windows xp.
Well I solved reading the
:help usr_01.txt
It said that is necessary to run this command !cp -i $VIMRUNTIME/vimrc_example.vim ~/.vimrc inside vim, it just copy a .vimrc to home user.
I close and opened vim and :Explore, Hexplore, Vexplore worked.
I had the same problem as well. Since it's a fresh install of Vim you don't have a .vimrc (or _vimrc on Windows). A vimrc is Vim's configuration file, and once you have one Vim will no longer try to be compatible with Vi (usually what you want).
So all you have to do is create a vimrc file and you should be ready to :Explore all you want. Below are locations you can put your vimrc file, and the filename to use for it. (depending on your system)
Unix/Linux/OSX: $HOME/.vimrc or $HOME/.vim/vimrc
MS-Windows: $HOME/_vimrc, $HOME/vimfiles/vimrc
or $VIM/_vimrc
sources:
* :help 'compatible'
* :help 'vimrc'
I also recommend following atomsfat's answer as well to give you a simple vimrc to start out with.
Those commands are provided by the netrw plugin. Check :scriptnames to see if that plugin is loaded.

Resources