Vim language highlighting has quit working only for one specific file.
I've been using Vim in WSL (Ubuntu) for several months now without problems. My PC is Windows 10 Professional. Strangely, Vim is no longer highlighting properly when I open a particular file. Everything works fine with every other file, but if I open this one file, it does not display correctly. The language highlighting is gone. Line numbers, tabs, and end-of-file-tildes still follow the color scheme, but my actual code is simply colored white. Does anyone know how to fix this?
More details:
The file type is *.v
If I rename the file, it displays correctly.
If multiple files are open at once (i.e. split view), every other file displays fine while this one file does not.
The problem arose in the middle of a work session, and I changed nothing in the vimrc before the problem arose.
After seeing the problem, I ran apt-get update and apt-get upgrade, followed by a restart.
I tried changing the color scheme in my vimrc.
Nothing I tried worked. Any ideas or insight would be greatly appreciated. Thanks!
EDIT: This question will be moved to vim.stackexchange.com
I have one mapping to toggle syntax, maybe it will help you
nnoremap <silent> <expr> <Leader>s exists('g:syntax_on') ? ':syntax off<cr>' : ':syntax enable<cr>'
Whenever I type " in normal mode in vim it never appears - the editor (I tried both on Ubuntu 16.04 and macOS 10.13 with terminal vim as well as Spacemacs with evil) does not react - double quote does not appear in the command line, nor editor pastes anything when I use, e.g. "+p. I verified with :reg that I have all default registers and they are filled with data.
What can be the source of the problem and how to fix it?
I very often come with a case where "0p or "*p would fit perfectly and have to deal with them manually.
In Vim, a very useful keyboard shortcut is ctrlxctrll (that's a lowercase L) which will complete the entire line you're typing based on lines in all open buffers. My linewise completion has stopped working.
When I type (in insert mode) ctrlx it correctly shows me ^X Mode (...^L) in my status line, but when I hit ctrll Vim just beeps at me and outputs nothing.
I have 54 plugins and update my .vimrc often. How can I debug this shortcut? Is there a way to see what a double stroke motion is mapped to?
Turns out this was because I was using the software Karabiner which ironically is designed to give you Vi mode in various parts of OSX. The specific setting I had enabled was ctrl-hjkl in any inputs would map to up/down/left/right. I discovered this by running vim -u NONE to run Vim without plugins, and as it still presented the error, I realized the problem lied outside of Vim.
I've just downloaded GVIM for the PC and MacVIM for the Mac and they both have different behaviour to the VIM I was using in MSYS.
Here's the problem. I bring up a file in VIM and enter insert mode. I can no longer delete any of old text. I can insert new text and delete them just fine so I know my backspace and delete keys are working. What's even more annoying that if I move the cursor to another line and come back to my original one, the new text I've typed becomes undeletable as well.
The command line VIM allows me to delete old text in insert mode but the GUI versions do not. I've looked in the options and googled but have not come up with anything.
Does anyone know how I can make the GUI version behave like the command line version of VIM?
Check the output of
:set backspace?
It will likely say something like
backspace=indent,eol
This means you can hit backspace to delete over end of line and indent characters. To be able to delete text that was present before you went into insert mode, you need to add 'start'.
:set backspace=indent,eol,start
This is equivalent to
:set backspace=2
For more details see
:help 'backspace'
The vi in msys is just an older version of vim. (5.8.9 in msys 1.0.10). So either the defaults changed or you are using a different settings file for gvim than you are for msys.
I've been getting more and more comfortable using vi on a daily basis, but one thing that bothers me is that when I use it on Ubuntu it behaves differently than when I use it on CentOS (and probably other places). I actually prefer the way it works in CentOS.
Here are three things that are really bothering me on Ubuntu:
In CentOS insert mode there is a big bold notice at the bottom that I'm in INSERT mode, but in Ubuntu there is no notice so I can never tell which mode I'm in.
In CentOS insert mode I can press the up/down keys and the cursor will move up and down. But when I'm in Ubuntu pressing up and down inserts the letters A and B respectively on new lines.
In CentOS insert mode I can use the backspace key and it will delete the character that is before the cursor, but in Ubuntu I just hear a beep sound and nothing happens. I can press the delete key in command mode, but I'd rather be able to press the backspace key.
Are these differences something that I have to live with or is it an easy fix?
In ubuntu, the default vim install comes from the package vim-tiny, which isn't the whole thing.
You probably want to:
apt-get install vim
or
apt-get install vim-full
Some of your other problems sound like issues with the backspace key and other things. Once you get the full version of vim, try adding these to your .vimrc:
set nocompatible
set t_kb=^H
fixdel
(IMPORTANT NOTE: that ^H is a literal ctrl-H character, which you'll get by doing Ctrl-V Ctrl-H in insert mode)
The previously offered answers did not work for me.
I tend to prefer leaving OS installations as stock as possible and keeping config files as simple as possible. In order to fix these three issues in Ubuntu 12.04, I did the following:
In "~/.vimrc", insert the lines -
set nocp
set bs=2
In addition to installing vim-full, if you do not already hava a ~/.vimrc:
$ cp /usr/share/vim/vimcurrent/vimrc_example.vim ~/.vimrc
This example .vimrc already makes the most important settings and is a good start for customization.
I'll assume you mean VIM when you say VI? And at least, the 2nd point seems to be a console/terminal issue with VIM/term combo. The page below suggests some fixes, but none that I could make work (I use vim over putty to an Ubuntu dev box)
http://vim.wikia.com/wiki/Fix_broken_arrow_key_navigation_in_insert_mode
3rd point can be overwritten by using the following in your .vimrc
set backspace=indent,eol,start
(1) Check if showmode setting is different on both.
(2) Don't know about this one, I think this has more to do with the terminal than Vi itself.
(3) Maybe try using :map <BS> :normal d ?
In CentOS, vi is an alias for a different program, vim, but in recent versions of Ubuntu, vi means just vi, not vim. The difference you see if the difference between two different programs, vi and vim.
If you like vim, just run vim, not vi. This works in Ubuntu too
Setting this in my .vimrc worked for me..
set term=builtin_ansi
I Have WDMyCLoud with Debian 7 inside, im using like:
cp /usr/share/vim/vimcurrent/debian.vim ~/.vimrc
In my case, the .vim file is created as follows:
set nocompatible
fixdel
If I add set t_kb=^H, the backspace key just hehaves as delete key.