How to add Syntax Highlighting in Vim for .ini files - vim

I recently started using Vi Improved and being a Rainmeter Skin Specialist, when editing my .ini files I can't find a way to add syntax highlight for such files. I searched for a lot of time on stack and git and turned up to nothing. Requesting help at the latest.
TLDR; Need .ini file syntax highlighting for Vim

Vim already has syntax highlighting for *.ini files.
If your Vim is reasonably recent, say 8.0 and up, and you didn't set anything up with regards to Vim (no $HOME\_vimrc, nothing), then your *.ini files should be highlighted without any human intervention at all.
The screenshot below was taken in a test VM with a basic Vim without any setup:
If you have already customised Vim, with a $HOME\_vimrc file and/or with a $HOME\vimfiles directory, then you are in full control, which means that the automatic stuff described above is no longer done for you anymore. And being in full control of Vim pretty much requires that you learn it properly and configure it as you go.
Having EITHER of the following lines in your $HOME\_vimrc or $HOME\vimfiles\vimrc is going to give you automatic syntax highlighting for any recognised filetype:
syntax enable
syntax on

Related

vim81 configuration wrong after I added .vimrc

I uninstalled vim74 and compiled vim81 and installed it. However I found it strange, comparing to vim74. When there's no .vimrc file under HOME dir, I open a c++ file and syntax highlight is working and I can use Backspace to delete letters. However when I add a .vimrc under HOME dir and just put set number into it, when the c++ source file is opened, no highlight, and Backspace not working. Why is that ? I used to add some configurations in .vimrc under vim74 before, and this situation never happens.
After complaints that Vim in its default configuration is hard to use (especially for beginners), it was decided to enable a default configuration if the user hasn't created his own ~/.vimrc (yet). This was introduced with Vim 8.0, and explains what you're seeing (namely: syntax highlighting and sensible backspace behavior). Read more about the details at :help defaults.vim.
The help also has instructions how to keep the defaults when adding your own ~/.vimrc configuration:
If you create your own .vimrc, it is recommended to add these lines somewhere
near the top:
unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
Then Vim works like before you had a .vimrc.
Tip: Don't go all crazy with adding various snippets (especially not those you don't fully understand) and plugins to your ~/.vimrc, even though the Internet is full of them. Rather, build it up gradually, depending on needs, and back up your understanding with careful studying of the excellent :help. Also, avoid pre-packaged Vim distributions; they're even worse.

How to make vim point to a syntax file located at a custom path

I'm trying to add a custom syntax highlighting file mysyn.vim in the syntax library of vim. Unfortunately, as I'm not the administrator I don't have access to usr/share/vim/vim72/syntax space. Hence, I was wondering if there is a way I can place the syntax file in my local area /home/doug/mysyn.vim and make vim look at this file by editing the .vimrc (.vimrc file is in my local space as well).
To get over this problem, I also considered copying my entire vim directory from usr/share/vim to /home/doug/myvim/ and change the default runtime path of vim. I tried doing this by adding the line let $VIMRUNTIME=\home\doug\myvimfiles\ to the .vimrc file. However, I get an error saying VIMRUNTIME : Undefined variable
So, are there any suggestions of how I could do this?
Thanks
With a decently recent version of Vim you can just create a directory ~/.vim/syntax and put syntax files there. You seem to be running Vim 7.2 though, which is some 8 years old. Getting your sysadmin sacked might be the better choice. :)

Vim directory with macvim/terminalvim

I am using mac vim in terminal via /Applications/MacVim.app/Contents/vim
By now I didn't really care about what was in the MacVim directory in /Applications/MacVim.app/Contents/Resources/vim/runtime
and still somehow I had proper syntax highlighting etc.. I guess my vim loaded the files from macvim?
Somehow I messed arround with snipmate and all the syntax highlighting stopped to work. Filetypes are correct, but no highlighting. So I copied the syntax folder from the macvim app to my ~/.vim/syntax and it worked like a charm. Is there a way how I can use the ones from the app again?
Thanks for any help
Copying the syntax to your own ~/.vim/ directory effectively forks the factory-defaults. The downside is that you now have to update your copy whenever Macvim is updated.
The key to figuring out the problems is the 'runtimepath' setting. By modifying that (in your ~/.vimrc), you should be able to include the proper runtime files (and that is not just syntax, but also filetype plugins, should you have :filetype plugin on). BTW, it's unlikely this is caused by snipMate.
:set runtimepath?
Also, the :scriptnames command tells you exactly which scripts have been sourced so far.

How do you set up formatting in vim?

Earlier, when I used open .py files in vim on ubuntu, they would be well formatted, with separate colours for separate segments of the program. Now, when I am using VIM on ubuntu, all the text in the .py file appears black. How can I correct this?
Formating in Vim means text formatting; e.g. indenting lists and breaking long lines. You're concerned about syntax highlighting, which is purely about the visual appearance of code.
First, it needs to be turned on.
:syntax on
does that.
Second, you probably want Vim to automatically detect the used language (e.g. Python) and choose the correct syntax plugin for you.
:filetype on
does that, though you usually enable more via :filetype plugin indent on.
To make these settings persistent, put them into your ~/.vimrc configuration.
Check man vim. In a nutshell, find a copy of a vimrc file, one might be under /usr/share/vim/ subtree. It may be named vimrc_example.vim. Copy to your home directory and rename it as .vimrc.

Text highlighting and cross-reference warning in Vim LaTeX with harvard.sty on MikTex 2.9

I used Vim LaTeX for six months with natbib and had no problems. But to use a new bib style file (i.e., rfs.bst) I started using harvard.sty, which gives me two minor problems:
(1) syntax highlighting is not complete; specifically for \citeasnoun, Vim only highlights the \cite portion. With another Vim plugin (Vim-plugin-R) I can update the syntax highlighting, but I can't figure out how to do this in Vim. I refreshed the databases in MikTex, but that didn't work.
(2) Vim LaTeX is automatically rerunning as necessary to get references correct -- the status window in Vim shows it going through several runs and the results are as desired -- but I still get this warning:
|| LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
How can I fix these? Thanks!
As for the syntax highlighting issue, you could try the following.
In your personal vim settings folder -- typically $HOME/.vim/ on Unix-based systems, or C:\Users\<yourname>\vimfiles (?) on Windows (probably the first entry shown in :set rtp?), create a directory (if there isn't one already) called after, and create a subdirectory of it called syntax, and in it create a file called tex.vim. So the file will be $HOME/.vim/after/syntax/tex.vim for Unix or C:\Users\<yourname>\vimfiles\after\syntax\tex.vim on Windows. (I hope a Windows user will confirm this, since I'm on Linux.)
In that file, put the following line:
syn match texRefZone '\\citeasnoun\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
Then when you open a LaTeX file, \citeasnoun should be treated just like \cite as for Syntax Highlighting (...that's assuming you're using the default Syntax Highlighting rules for LaTeX files that came with vim 7.3 anyway....)
I think your other question is answered in the comments.

Resources