How exactly should I use the source command to avoid getting errors - vim

So I'm trying to use the source(:so) command but I keep getting this error:
E471: Argument required
I would appreciate knowing what I could be doing wrong.

:source can be used in two ways:
" sources file foobar.vim
:source foobar.vim
" evaluates each line in [range] as vimscript
:[range]source
but the latter is a recent addition.
The fact that you can't use :source without an argument suggests that either your version of Vim is outdated or you are using Neovim, which apparently hasn't merged that patch already.

Related

How to get .vimrc ignore backtick

I'm using proprietary language that has syntax similar to javascript. In my .vimrc I have set BufReadPost for the file set syntx=javascript which works for most of the part except for backtick.
Unlike in .js, backtick is used to iterate over matrix without closing backtick. Since .vimrc is treating it like a js syntax it expects closing ` or else everything afterwards is string. How do I tell vim to ignore backtick.
In general, modifying an existing syntax script is difficult, as there are many complexities and interactions of parsing groups. However, small adaptations are possible.
If you're using the default JavaScript syntax that ships with Vim, it uses this definition for the backticks:
syn region javaScriptStringT start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=javaScriptSpecial,javaScriptEmbed,#htmlPreproc
To get rid of it, you can :help :syn-clear it:
:syntax clear javaScriptStringT
To apply this automatically, the command has to run after the syntax script has been sourced. Use the after-directory, e.g. as ~/.vim/after/syntax/javascript.vim.
Alternative syntaxes
Especially in the JavaScript area, there are several competing syntax scripts. For example, I use this one; fortunately, it has a similar syntax line that can be cleared in just the same way.

Vim not recognizing some commands from vim-latex

I have vim-latex installed via Vundle and I'm trying to disable some annoying mapping that it sets up by default. From the docs I know that, for example, I can use the following command to unmap FEM:
call IUNMAP('FEM','tex')
But when I type that I get the error E117: Unknown function: IUNMAP.
I have installed vim-latex with Vundle by including Plugin 'LaTeX-Suite-aka-Vim-LaTeX' in my vimrc and I have just used the PluginUpdate command to update everything, which runs with no error, so I should have the latest version of the package.
Am I missing something here?
Actually, the problem you're having is related to where you're getting your vim-latex from.
With:
Plug 'LaTeX-Suite-aka-Vim-LaTeX'
You're getting it from here, which you'll notice hasn't been updated since 2010. Looking at the plugin/imaps.vim file in that repository, you'll see there's a definition for function IMAP(), but not for IUNMAP(), which was probably introduced after the last date that repository was synced...
Use this source instead:
Plug 'vim-latex/vim-latex'
Which will get it from here which is an official maintained location for this plug-in.
If you look at plugin/imaps.vim in that source tree, you'll notice function! IUNMAP is defined there.
Updating to the correct plug-in location should fix this problem for you (together with probably quite a few fixes from the last 10 years!)
The functions IMAP() and IUNMAP() are loaded by the vim-latex plug-in only after your vimrc is processed. So you need to execute them from a context where they're available.
Furthermore, in order to have your unmapping succeed, you need to actually execute it after the mapping was created, and mappings are typically created when the filetype is set.
The documentation mentions that these overriding rules should be done in specific files:
An important thing to note is that if you wish to over-ride macros created by Latex-Suite rather than merely create new macros, you should place the IMAP() (or IUNMAP()) calls in a script which gets sourced after the files in Latex-Suite.
A good place typically is as a file-type plugin file in the ~/.vim/after/ftplugin/ directory. [...]
For example, to delete a mapping, you can use
call IUNMAP('FEM', 'tex')
in ~/.vim/after/ftplugin/tex_macros.vim.
The documentation mentions that you should use a file in ftplugin after the filetype you use. Check :set ft? to confirm yours is indeed tex, in which case you can use tex.vim, tex_something.vim (like the suggested tex_macros.vim) or tex/something.vim (a subdirectory.)

How to get the value of minlines in Vim

Vim often shows wrong highlight when opening perl files contain pod paragraphs, use command
:syn sync minlines=9999
can handle this problem.I am curious about the value of minlines,so,which command will show minlines's value of current opened file? I didn't find that in vim reference manual.
I do not think there is a native command for that. I suggest you to check it out directly in syntax files. For example, about Perl, take a look at perl.vim. I am on Arch Linux and this file is available here: /usr/share/vim/vim80/syntax/perl.vim. If you go to line 435, you should see this: syn sync minlines=0.
Be aware that some syntax files define specific minlines rules. In Ruby/Java files, you should be able to call :echo ruby_minlines or :echo java_minlines respectively. This will not work with Python, PHP or JavaScript.
Finally, if you are ready to sacrifice a bit of performance for better ergonomics, you can add the following command to your .vimrc: autocmd BufEnter * :syntax sync fromstart
I use it to avoid annoying issues with syntax highlighting. It works great, but Vim will be extremely slow if you try to edit huge files...

How to make Vim Quickfix show errors in source files instead of the make file

So I am programming in C with VIM by using the make command to compile my code.
I would like to use the quickfix plugin to quickly move to the different compile errors but the only error that quickfix shows is the failed command in the make file.
I have failed to find any clues on google for this problem, is there something I could be missing to make this work?
The quickfix list (it's built in, not a plugin) parses the output of :make according to the rules in the 'errorformat' option, in order to extract file names, line numbers, and error messages.
Usually, you don't write those yourself, but you simply choose the appropriate compiler plugin. If your build uses GCC, you can set the compiler by
:compiler gcc
See :help compiler for details and a list of compiler plugins that ship with Vim.
I have finally solved the problem.
It turns out that if your shell is set to use FISH the output of the make command displays correctly but for some reason quickfix is unable to pick up any errors except for the failed part in the make file.
I solved the problem by switching vim to use bash instead by adding set shell=/usr/bin/bash to my .vimrc file.

.vimrc causes error (E10: \ should be followed by /, ? or &)

I've copy pasted this .vimrc into my /etc/vimrc in Fedora 15. Every time I use vim for anything, I get a number of errors with line numbers which don't seem to be the correct line numbers of my vimrc file because there aren't any '\'s on those lines.
I've googled this and there is a similar stack overflow question, but I believe it is irrelevant to my question.
I also removed everything that said MySys() == linux/max/windows or etc because I'm using linux so I just used the linux lines.
Any ideas?
Edit---
Here's my (barely) modified vimrc file:
https://docs.google.com/document/d/1PznK0FizGlBr6W6m9wikM334q8b6KFFCgmsF-f8MX3s/edit?hl=en_US
Error you mentioned here normally happens in one of the following cases:
You are trying to use line continuation inside :execute.
You are trying to use line continuation when vim is in compatible mode.
To remove the second case run vim using vim -N. If no errors appear, add set nocompatible at the top of the vimrc. If errors still appear, search for exe (as :execute can be truncated to :exe) and check out whether somewhere line matching \n\s*\\ is passed to :execute.

Resources