vim81 configuration wrong after I added .vimrc - vim

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.

Related

How to add Syntax Highlighting in Vim for .ini files

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

Vim weird behaviour with backspace with empty .vimrc

I'm having a weird issue with vim on Ubuntu. I've been using it for the last few weeks, trying to learn, on Windows and it behaves differently now that I'm using it on Linux.
I noticed that while in insert mode pressing backspace will delete text just like any other editor on Windows, but on Linux the text is "deleted" yet it stays there until I press ESC or write over it.
I was trying to fix this but I'm confused as to whether this is intended behaviour or not. It happens in gvim too.
The reason of this question is this, however:
I deleted my .vimrc file to see if any of my config was at fault and it fixed it. Backspace was now back to its regular self.
But then I tried creating an empty .vimrc file and that made it go back to the delayed delete. It's empty. Why the hell?
So I have no idea what's causing this. Hope my question makes sense my English ain't the best. Thanks.
Alright so looking at :h compatible I found this:
"When a |vimrc| or |gvimrc| file is found while Vim is starting up,
this option is switched off, and all options that have not been
modified will be set to the Vim defaults. Effectively, this means
that when a |vimrc| or |gvimrc| file exists, Vim will use the Vim
defaults, otherwise it will use the Vi defaults. (Note: This doesn't
happen for the system-wide vimrc or gvimrc file, nor for a file given
with the |-u| argument). Also see |compatible-default| and
|posix-compliance|."
So if I'm getting this right, running Vim with a .vimrc file should automatically set nocompatible and running it without one should set compatible... ? Whatever the case, I tried checking with :verbose set compatible? and it always says nocompatible is on so the -N flag shouldn't do anything... Yet it fixes the issue.
Without a vimrc Vim will load /usr/share/vim/vim80/defaults.vim (depending on your vim version). In this file the bs/backspace parameter is set to 2, or actually it is indent,eol,start which is the same as 2 (see :h bs)
Now if you create an empty .vimrc, defaults.vim will not be loaded, so your bs will possibly be 0.
This behaviour is described in :h defaults.vim
So to solve your problem, just put set bs=2 in your .vimrc
Alright I fixed it.
Running vim with the -N command makes it work properly. I'm not sure why but that's what's happening.

Julia syntax highlighting in julia-vim

I use gvim with julia-vim for editing julia code. I am using julia 0.5 on a mac and installed julia-vim with vundle.
My problem is that files with the .jl extension do not have appropriate highlighting. For example, if is highlighted but for is not. Any solution for this?
.jl files are sometimes recognized as lisp files by default, (blame Sawfish) so that's probably the syntax highlighting you're getting. (type defun and progn and etc and see if the pretty colors pop up)
You were close when you said the correct solution was :set syntax=julia, what you need is to set filetype plus some autocmd magicks to make that happen every time you open a .jl file.
Put something like this in some file (e.g. jl.vim) in your ftdetect directory:
autocmd BufRead,BufNewFile *.jl :set filetype=julia
And that should do it.
Addendum 1: Changing filetype instead of syntax may be required to trigger additional features like the LaTeX expansions depending on the root of your problem, so that's what I am using.
Addendum 2: Note that this should've been handled by the julia-vim plugin, but conflicts with other scripts can mess with that. You can use :scriptnames to see what scripts have been loaded and in what order, and try to debug what could be causing the conflict, if you think that's worth the trouble.
Addendum 3: Also related is that Vundle has some specific configurations that need to be made when it comes to filetypes, so that could also be causing this. However, I've seen this and similar problems happen outside Vundle for any number of reasons so I still believe that the solution at the top is the best one, and will possibly prevent some future headaches.
After testing julia-vim I think the issue is likely with the color scheme you are using.
Try using a different one.
:colorscheme desert
I tried it with the built-in desert and both if and for were highlighted (see below).
I found that the instructions here worked a treat. Namely
git clone https://github.com/JuliaEditorSupport/julia-vim.git
mkdir -p ~/.vim
cp -R julia-vim/* ~/.vim
Note: I realise that the OP claims to have already installed Julia-Vim using Vundle, but I came to this question because Vim was automatically using LISP syntax highlighting for me, and the above was enough for me. So I am sharing in case anyone comes from the same boat as me (i.e. the problem is not Vundle related) :)

vim syntax highlighting weirdness

I have some specific settings for my latex highlighting and am using the indentLine plugin, which requires let g:indentLine_fileTypeExclude = ['tex', 'bib'] to avoid the conceal feature annoyance. Anyway, when I start vim with vim filename.tex my vimrc gets loaded properly, but when I simply call vim and then open a given tex file, it'll ignore the vimrc.
Any idea what's causing it? Also, let me know what information you need, as I am far from certain on what would be needed.
EDIT:
Okay so I've found that for both cases i'm in a [tex] environment, but if I'm in a [plaintex] environment then the weirdness doesn't happen. If that helps anyone.
2nd EDIT:
New development, it is only the first file that's opened that seems to ignore the exclusion for indentLine, the remainder are shown exactly as they ought to.
The plaintex is a separate filetype in Vim (cp. :help ft-plaintex), so you need to add it to the IndentLine config:
let g:indentLine_fileTypeExclude = ['tex', 'plaintex', 'bib']
Edit This now looks like a command ordering issue. It's hard to remotely troubleshoot this, as the exact plugins and their initialization order may be important. Please capture a full log of a Vim session with vim -V20vimlog. After quitting Vim, examine the vimlog log file for the ordering of commands (but it might be difficult to see what's happening in a potentially vast list of commands).
It might be sufficient to just reload the first file that has those problems, with :e!.

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.

Resources