You are not logged in.

#1 2023-02-28 22:30:48

geronimopink
Member
Registered: 2023-02-27
Posts: 7

[SOLVED] vim syntax not working

Hello and thanks for your time and help.
I am trying to get syntax on when writing html, in vim. I am missing something and I can not get it to work.
I would appreciate any help.
Here is my /.vimrc file

" An example for a vimrc file.
"
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last change:	2019 Dec 17
"
" To use it, copy it to
"	       for Unix:  ~/.vimrc
"	      for Amiga:  s:.vimrc
"	 for MS-Windows:  $VIM\_vimrc
"	      for Haiku:  ~/config/settings/vim/vimrc
"	    for OpenVMS:  sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings, bail
" out.
if v:progname =~? "evim"
  finish
endif

" Get the defaults that most users want.
source $VIMRUNTIME/defaults.vim

if has("vms")
  set nobackup		" do not keep a backup file, use versions instead
else
  set backup		" keep a backup file (restore to previous version)
  if has('persistent_undo')
    set undofile	" keep an undo file (undo changes after closing)
  endif
endif

if &t_Co > 2 || has("gui_running")
  " Switch on highlighting the last used search pattern.
  set hlsearch
endif

" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
  au!

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78
augroup END

call plug#begin()
" The default plugin directory will be as follows:
"   - Vim (Linux/macOS): '~/.vim/plugged'
"   - Vim (Windows): '~/vimfiles/plugged'
"   - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
"   - e.g. `call plug#begin('~/.vim/plugged')`
"   - Avoid using standard Vim directory names like 'plugin'

" Make sure you use single quotes

" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'

" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'

" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

" On-demand loading
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }

" Using a non-default branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }

" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }

" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }

" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }

" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'

" Initialize plugin system
" - Automatically executes `filetype plugin indent on` and `syntax enable`.
call plug#end()
" You can revert the settings after the call like so:

filetype plugin on 
filetype indent on   " Disable file-type-specific indentation
syntax on          " Disable syntax highlighting

" Add optional packages.
"
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
" The ! means the package won't be loaded right away but when plugins are
" loaded during initialization.
if has('syntax') && has('eval')
  packadd! matchit
endif

"syntax"
: set syntax=on

Last edited by geronimopink (2023-03-08 17:20:11)

Offline

#2 2023-03-01 03:38:37

Adriik
Member
From: Argentina
Registered: 2022-03-10
Posts: 134

Re: [SOLVED] vim syntax not working

Try removing the :set syntax=on

You use that if you want to set a specific syntax in a file
For example, I have a C code call just main, without a extension, so I can set the syntax to C with :set syntax=c to show the file with C syntax, instead as a plain text.

Last edited by Adriik (2023-03-01 03:39:13)


Solo soy un loco más. Please use [code] [/code] tags.
Command cheatsheetCommand not found?
If I write something wrong in English, please correct me.

Offline

#3 2023-03-08 16:52:58

geronimopink
Member
Registered: 2023-02-27
Posts: 7

Re: [SOLVED] vim syntax not working

Thank you for your input, unfortunately removing ":set syntax=on" did not change anything.

Offline

#4 2023-03-08 16:58:46

Adriik
Member
From: Argentina
Registered: 2022-03-10
Posts: 134

Re: [SOLVED] vim syntax not working

From :help syntax in Vim

1. Quick start                        *:syn-qstart*

                        *:syn-enable* *:syntax-enable*
This command switches on syntax highlighting: >

    :syntax enable

What this command actually does is to execute the command >
    :source $VIMRUNTIME/syntax/syntax.vim

If the VIM environment variable is not set, Vim will try to find
the path in another way (see |$VIMRUNTIME|).  Usually this works just
fine.  If it doesn't, try setting the VIM environment variable to the
directory where the Vim stuff is located.  For example, if your syntax files
are in the "/usr/vim/vim82/syntax" directory, set $VIMRUNTIME to
"/usr/vim/vim82".  You must do this in the shell, before starting Vim.
This command also sources the |menu.vim| script when the GUI is running or
will start soon.  See |'go-M'| about avoiding that.

                            *:syn-on* *:syntax-on*
The `:syntax enable` command will keep most of your current color settings.
This allows using `:highlight` commands to set your preferred colors before or
after using this command.  If you want Vim to overrule your settings with the
defaults, use: >
    :syntax on

And looking my vimrc file, I have the two: syntax enable and syntax on.


Solo soy un loco más. Please use [code] [/code] tags.
Command cheatsheetCommand not found?
If I write something wrong in English, please correct me.

Offline

#5 2023-03-08 17:19:51

geronimopink
Member
Registered: 2023-02-27
Posts: 7

Re: [SOLVED] vim syntax not working

It does work now with both entries, thank you very much!!!

Offline

Board footer

Powered by FluxBB