I
I
Ivan Semenov2017-07-15 10:58:46
vim
Ivan Semenov, 2017-07-15 10:58:46

How to make vim highlight syntax in .conf files?

Good day everyone!
I ran into a problem here, although it is a little strange. There are two machines, both are running FreeBSD 10.3-RELEASE, installed the vim editor on both machines. But an incomprehensible situation arose. On one machine, the syntax in the editor is highlighted in all files, but only in the configuration files of vim itself and newly created ones, but in rc.conf it does not want to highlight in any way.
Configuration from the first machine /usr/local/etc/vim/vimrc

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
        set fileencodings=ucs-bom,utf-8,latin1
endif

let g:is_posix = 1
set nocompatible
set bs=indent,eol,start
set history=50
set ruler

if &t_Co > 2 || has("gui_running")
        syntax on
        set hlsearch
endif

if has("autocmd")
        augroup freebsd
        autocmd!
        if $PORTSDIR != ""
                autocmd BufNewFile $PORTSDIR/*/*/Makefile 0r $PORTSDIR/Templates/Makefile
        else
                autocmd BufNewFile /usr/ports/*/*/Makefile 0r /usr/ports/Templates/Makefile
        endif
endif

Configuration from the second machine /usr/local/etc/vim/vimrc
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
        set fileencodings=ucs-bom,utf-8,latin1
endif

let g:is_posix = 1
set nocompatible
set bs=indent,eol,start
set history=50
set ruler

if &t_Co > 2 || has("gui_running")
        syntax on
        set hlsearch
endif

if has("autocmd")
        augroup freebsd
        autocmd!
        if $PORTSDIR != ""
                autocmd BufNewFile $PORTSDIR/*/*/Makefile 0r $PORTSDIR/Templates/Makefile
        else
                autocmd BufNewFile /usr/ports/*/*/Makefile 0r /usr/ports/Templates/Makefile
        endif
endif

The configurations are identical.
And here's another feature: on the first machine, I can scroll the open file with the mouse wheel and put the caret on any line with the mouse cursor, and copy and paste is carried out only while holding down the shift key, and on the second everything is as usual.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kaN5300, 2017-07-20
@kaN5300

The problem with copy-paste in visual mode is treated by adding the line set mouse=v to vimrc. Do you have exactly the same vim installed on both wheelbarrows? $pkginfo | grep vim
I prefer to just put one reference .vimrc with all the settings into my user's hamster on the newly installed server and work with highlighting and all the necessary features.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question