-1

I use vim as my text editor, and I want to make use of highlighted syntax. However, I cannot get it to work when I use the command “syntax on” in my ~/.vimrc file.

The strange thing is that it does the syntax is highlighted in the ~/.vimrc file itself, but not in other files.

When I use the command “syntax on” in my ~/.vimrc file, it does highlight the text in the ~/.vimrc file itself, but not in other files. If I provide other commands in the ~/.vimrc file they work: colorscheme wors, set number also works. So the ~/.vimrc file itself is actually used and works correctly, only the “syntax on” command does not work.

Anybody who can help me with this?

Thanks in advance!

Roy
  • 1
  • 1
  • Can we see the **full** output of `$ vim --version`. – romainl Dec 25 '22 at 18:14
  • Your question is not internally consistant. You say that syntax highlighting doesn't work but you also say that "colorscheme wors". So what can we do with this? – romainl Dec 25 '22 at 18:16
  • I tried “colorscheme blue” and it results in a blue background, with the yellow color text. However, syntax highlight is not working because the entire text has the same color. I will check the extact output of “vim —version” when I have access to my laptop – Roy Dec 25 '22 at 18:20
  • https://vi.stackexchange.com/ – Rob Dec 25 '22 at 18:34
  • We will need the content of your `vimrc` as well, and a command-by-command description of what you are doing. – romainl Dec 25 '22 at 22:29
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 26 '22 at 07:50

1 Answers1

0

I have found the issue. Beginners mistake I guess...

As mentioned the comments, in the .vimrc file syntax highlighting worked fine. In the files I made myself, I just opened a file without extension (i.e. vim testfile).

In a file without extension, the syntax highlighting does not work because vim does not know how to highlight the syntax. When I now for instance open a file vim testfile.py (with the Python extension), it works fine.

Thanks anyway for your comments!

Koedlt
  • 4,286
  • 8
  • 15
  • 33
Roy
  • 1
  • 1