Vim Syntax Highlighting does not work - vim

I've installed a fresh Arch Linux system on my laptop and downloaded the vim package.
I haven't altered the .vimrc file, but the syntax highlighting doesn't seem to work with any of the languages I tried (Python, Ruby, CSharp, C...).
Auto formatting (gg, =, G) also fails.
Until now when playing with vim (because I can't really say I've extensively used it) in other OSs (Ubuntu, Fedora), the syntax highlighting came on automatically.
Is there something I am missing here?

You need to have following settings in .vimrc file as per arch linux documentation
filetype plugin on
syntax on

This is the absolute minimum you need to put in your ~/.vimrc if you intend to use vim as your primary editor:
" activates filetype detection
filetype plugin indent on
" activates syntax highlighting among other things
syntax on
" allows you to deal with multiple unsaved
" buffers simultaneously without resorting
" to misusing tabs
set hidden
" just hit backspace without this one and
" see for yourself
set backspace=indent,eol,start
Anything else depends on your taste, workflow and needs.

vi /etc/profile
alias vi=vim
maybe you use vi instead of vim

I had this problem in Opensuse Leap 42.2 cloud. And solved it by installing vim-data
sudo zypper install vim-data
or just re-installing vim will include vim-data automatically.
sudo zypper remove vim
sudo zypper install vim

Type
:syntax on
to get it to work. It is not a default option for vim. Probably in the other systems, it was set to on in the system default vimrc
Or put
syntax on
in ~/.vimrc

Another reason syntax highlighting won't work is you might have a theme/colorscheme set that VIM cannot find.
colorscheme darkblue
Either delete the line or comment it out:
"colorscheme darkblue

I had a similar problem. I could not have syntax highlighting on. I also found that gvim launched without pulldown menus or toolbar icons. It turned out I did not have the vim-runtime package properly installed. In my case I was on debian jessie with a large set of files missing under /usr/share/vim/vim74/ directory.
$ ls /usr/share/vim/vim74/
debian.vim doc/ rgb.txt
The solution was to run:
$ sudo aptitude reinstall vim-runtime
That fixed the problem for me, for syntax highlighting and for missing menus/icons in gvim. I'm not sure why my system was in this state, but the reinstall of the above package solved both issues.

in my case , I changed the term(terminal type) from vt100 to xterm. And it works.
To change the terminal type:
in bash:
export TERM=xterm
in bourne shell or ksh:
TERM=xterm
export TERM
in csh or tcsh:
setenv TERM xterm

On my Ubuntu 18.04 system i.e. c-highlighting works but Icinga2 config file highlighting being provided by the vim-icinga2 package does not. Quote from https://packages.debian.org/sid/vim-icinga2:
As per the Debian vim policy, installed addons are not activated automatically, but the "vim-addon-manager" tool can be used for this purpose.
Executing vim-addon-manager -w install icinga2 following a regular vim-icinga2 package installation solved the issue. The -w option forces a system wide rather than a just per current user activation. Notice that executing vim-addon-manager without arguments yields a list of 39 modes being disabled by default:
> vim-addon-manager
# Name User Status System Status
align removed removed
alternate removed removed
...
icinga2 removed installed # Due to above command
...
If you do miss highlighting chances are your mode is among this list.
NB: Ubuntu 18.04 seemingly inherits Debian's policy. None of the above answers solved my issue. No ~/.vimrc configuration or manual activation was being required after the above described activation.

Related

The nord color scheme for vim does not match the documentation

I installed the scheme according to the instructions, but the colors are still not as in the documentation.
https://github.com/arcticicestudio/nord-vim
OS - ubuntu 14, connecting via ssh.
Applied, restarted vim.
:PlugInstall
~$ vim ~/.vimrc
Error detected while processing /home/test/.vimrc:
line 17:
E518: Unknown option: termguicolors
Press ENTER or type command to continue
From the error it looks like you don't have that feature compiled on your
version of vim. Although it's not clear to me if you have set termguicolors
in your .vimrc because it was part of the installation instructions or not.
Either way, from :help: termguicolors:
'termguicolors' 'tgc' E954
'termguicolors' 'tgc' boolean (default off)
global
{not available when compiled without the
+termguicolors feature}
You can check if you have the 'termguicolors' feature by doing:
:version
and seeing if the 'termguicolors' has a '+' in front of it (you have it) or a
'-' in front of it (you don't).
Resolved problem.
Indeed, the problem was the lack of termguicolors.
Ubuntu was vim running version 7.4..
termguicolors has been added to vim since version 8. I had to update vim.
Thank you all.
vim --version
sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim
vim --version
The error is fairly self-explanatory: you are setting an option that is not available in your Vim.
You have a few ways to get out of this situation…
Not setting the :help 'termguicolors' option at all.
Setting it conditionally:
if exists('+termguicolors')
set termguicolors
endif
See :help exists().
Installing a Vim build that includes the termguicolors feature (and making sure your terminal emulator supports it).
Note that this colorscheme's promised look can only be achieved in:
GUI Vim,
TUI Vim with the termguicolors feature built-in and the termguicolors option set, in a suitable terminal emulator,
in TUI Vim, if you change the colour palette of your terminal emulator.
You should have read the instructions before installing that plugin.

Vim Latex Suite can't find latex command using Pathogen

Background
I was having dual boot issues with Windows 10 and Ubuntu 17.10, which eventually resulted in a boot loop and since I need Ubuntu 16.04.3 for an Operating Systems class I decided to load up an ISO into one of my USBs with Rufus, reformat my Windows partitions from GPT to NTFS to get around some nasty bootmg/efi issues and here we are, good as new, except for one thing...
Problem
The only thing I haven't been able to successfully reinstall has been Latex Suite for Vim. Installation last time had been an easy extraction into .vim, but after some deliberation I elected to use Pathogen.
I've installed Pathogen using
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
Which works for color schemes, etc., and every other aspect of latex-suite save for compiling, generating this every time I try to compile (using \ll):
/bin/bash: latex: command not found
I installed texlive which does then allow me to compile using vim, but I'd prefer not to use this solution if I don't have to (in fact I've already removed it, its more of a plan b for now given it's obstructive and non-intuitive compilation errors). I looked at the other questions asking how to install Latex Suite through pathogen and didn't see anything else similar to what I'm working on; below is self-explanatory in regards to installation structure.
~/.vim/bundle$ ls
vim-archery vim-latex-1.10.0
Obvious running pdflatex and latex can't be found because they are not in my $PATH but I was under the impression that with a good, recommended package manager like Pathogen I wouldn't need to which is what originally raised the red flag for me as its whole job is to modify the runtime path. I thought maybe trying sudo vim text.tex might work in case there hadn't been adequate permissions for Pathogen to modify runtime path but no dice.
.vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
colorscheme archery
let g:tex_flavor='latex'
set sw=2

Why vim is changing first letter to g after opening a file

When I open a file, eg vim .bashrc, vim opens the file and change the first letter to g. What I see is the following:
g To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
...
I change g back to #, but after loading the file its again changed. Happens with multiple files.
Last things I have done was: installig gcc and make.
Why is this happening?
EDIT:
My .vimrc file:
set nocompatible
set backspace=indent,eol,start
set number
set tabstop=4
syntax on
I had the exact same problem
I found out it was a bug in my ssh client (mobaXterm).
Updating (to mobaXterm 'personal edition v9.1') resolved the issue.
I am using vim on Ubuntu Linux 16.04 via MobaXterm version 7.7. This is an older version of MobaXterm that supports command-line-settable terminal background colors.
The following change to my .bash_profile solved this problem for me:
# Fix for Vim 8.0 bug that stomps on line 1 char 1:
export TERM=linux
Strange enough, but it works for me. I created a ~/.vimrc file:
syntax on
set background=dark
The 2nd option disable the bug.
So it appers to be a vim issue. So far I gathered only two solutions:
Reinstall to older version of vim. i reinstalled to 7.4.752-1 and bug is gone.
Change cygwin terminal to anyone but "xterm*" (right-click on title bar -> Options... -> Terminal -> Type)
For me, I traced the issue down to the following line:
set nocompatible
It is found in /usr/share/vim/vim74/debian.vim, which is included from /etc/vim/vimrc with the line runtime! debian.vim
make sure you dont set the visual bell in your .vimrc
set visualbell
in case you have it then just delete it :)
The exact same thing was happening to me! It wasn't occurring in gvim, so I thought maybe something was going on in my .vimrc. I zeroed-out my .vimrc but it was still happening. Only when I completely deleted my .vimrc did this behavior stop. As suggested,I rolled back to an older version (7.3.1152-1) with cygwin setup and that fixed it. I did not have to change any terminal settings, however. It makes sense because I updated cygwin yesterday, when I started seeing the errant g's.
I am on ArchLinux. vim 8.0.0987-1 always decreases a number upon opening a file (as if xtrl+x pressed). Downgrade to 8.0.0722-1 fixed the issue.

Why can't this menu item work?

I got this in my vimrc:
:so menu_format.vim
and in menu_format.vim, this:
"... other menu items that work
menu Format.nbsp_space <ESC>:%s# # #gec<CR> //(the 1st blank is 0xa0, the 2nd is 0x20)
"... other menu items that work
On Windows it works (been using it for a while), but on Linux Mint 17 vim gives:
E319: Sorry, the command is not available in this version.
I tried %s# # #gec on command line, it worked, too!
I knew how to fix this: %s#[\xa0]# #gec would do. I just wanted to know why there is such a difference, and it made me doubt the portability of my vim scripts.
BTW, I built vim (7.4.560) on both Linux and Windows with the same configuration, both use the same menu_format.vim.
It looks like you only have the minimal version of Vim named vim-tiny; it only provides a minimal vi-compatible implementation. The E319 implies that the :menu command is not available, the :substitute does look fine and should work.
To get the full Vim (and graphical GVIM), install the following package:
$ sudo apt-get install vim-gnome

vim-go autocompletion not working

I recently installed vim-go using pathogen, but the autocompletion feature is not working. If I am using it only shows commands I've already used.
My .vimrc has
filetype plugin on
" Enable autocompletion
set omnifunc=syntaxcomplete#Complete
" Select keyword as you type
:set completeopt=longest,menuone
Do I need more than just this plugin? The other feature I have tested so far are working (:GoRun, syntax highlighting).
This is on a Ubuntu machine.
Are you typing C-X C-O to open the autocompletation window? This works fine for me.
On the other hand, if you want to get real-time completion (completion by type) install the following plugins YCM or neocomplete
The syntaxcomplete#Complete ships with Vim, not the Go filetype plugin, and it has very limited capabilities (basically, just offering the language's keywords). No wonder you're disappointed.
The ftplugin/go.vim file sets the correct, custom completion of the vim-go plugin:
setlocal omnifunc=go#complete#Complete
So, just ensure that the 'filetype' setting is correct (go), and that you don't have any additional configuration that overrides the plugin's.
:verbose setlocal omnifunc?
can tell you.
If none of these suggestions solves your problem, try killing gocode from a terminal:
gocode exit (or killall gocode it that fails)
gocode -s -debug
In case of startup failure due to a lingering unix socket, simply remove it and try again. Once everything is working, you can terminate the debug enabled gocode process (the plugin will autostart as needed)
This is what worked for me. default gocode pkg seems to be no longer maitained. so update it with the one below.
my go and vim versions:
VIM - Vi IMproved 8.2
go version go1.16.4
follow the steps below:
gocode exit
go get -u github.com/mdempsky/gocode
run gocode in debug mode
gocode -s -debug
try the autocomplete.(vim-go C+X C+O)
viola! you should see the list like so:

Resources