After running :make in Vim, vim will jump to nonsenical files - vim

Sometimes I'll have an error in a file and the output from :make is something like this:
In file included from /path/to/some/src/file.cpp|22| 0:
And so when it jumps to that file, it doesn't jump to file.cpp, it jumps to the file named In file included from /path/to/some/src/file.cpp, which is clearly nonsensical. In general I like the jumping, just not when the error is of that form causing me to have useless files open instead of the real error I care about
Is there a way to make it smarter so that it jumps to the real error, which is on the next line, or at very least, only jump if the thing it finds is a real file?

You might want to modify the errorformat setting. See :help 'errorformat' and :help errorformat. To know the current value you can run :set errorformat?.

Related

vim does not go back to the same file when exit from external command

I'm trying to compile my tex file inside vim. I have a Makefile to do the compilation, and I just type :make to call it. Usually it works well, but sometimes vim does not go back to the .tex file where I called make. Instead, I find I'm in a .cls file after pressing "ENTER or type command to continue".
I wonder what's happening? And how to make it work as I expected -- going back to the original file? Thanks.
Looks like Vim found some errors in your code and tries to be helpful by jumping to the related file and line. According to :help make you should be able to avoid that by using :make! (notice the exclamation mark) instead:
If [!] is not given the first error is jumped to.
You can also call :make and let it open the file with the first error, then jump back to the original file by typing Ctrlo.
There is another question that might be related: How do I disable the "Press ENTER or type command to continue" prompt in Vim?
I am using this configuration:
map <F10> :w<CR>:!make<CR><CR>
Pressing F10 key in normal mode saves me the tex file and calls make and returns to editing the file.

What are some use cases of :e in Vim?

I was reading :help :edit but I really don't understand the following sentence:
This is useful to re-edit the current file, when it has been changed outside of Vim
And what does start all over mean in :help :edit!?
This is useful if you want to start all over again
Could anyone please provide some use cases of them?
"Changed outside of Vim" means that the file that you're editing has been written to by another program. :e will load the latest version, and :e! will do that even if you have unsaved changes.
Loading the current file from the file system is useful if you're following a log, or viewing a generated file that gets updated when you run :make and other situations.
One use for this is to throw away the changes you've made since the last save with :w and go back to the most recent saved version. Which is to say, it's not necessary for the file to have changed behind Vim's back for this to be useful. Although Vim has enough undo depth that you can usually undo your way to back to the unmodified state, it's cumbersome. You can easily "overshoot" and then have to redo. The status line shows you whether the file is [Modified] or not, but as you undo, it gets overwritten with information about each undo, so you have to use Ctrl-G to re-display the file status.
I had no idea :e by itself with no argument did this re-loading, by the way; I have been using :e% for years!

How to disable jumping to warning location after compile in vim-latex?

After compilation, vim-latex opens a quickfix buffer, lists errors and warnings, and jumps to the first error or warning in the list. How do I make it not jump for warnings? or better yet, for certain warnings?
If this is not possible, is there some shortcut for returning the cursor back to its position before the jump?
NOTE: Ignoring warnings via let g:TexIgnoredWarnings = ... is not adequate since I do want to see the warnings.
If you're compiling via Vim-Latex's \ll command as I do, then adding the following option in either your vimrc or the ftplugin tex.vim should solve your problem:
let g:Tex_GotoError=0
This will leave your cursor where it was, but still populate the QuickFix window with warnings and errors. The documentation (linked below) says that it defaults to on, so switching it off should accomplish what you want.
http://vim-latex.sourceforge.net/documentation/latex-suite.html#Tex_GotoError
I assume you are compiling LaTeX with the :make command. The help for that command gives a list detailing exactly what the command does, including:
If [!] is not given the first error is jumped to.
If you trigger your compilation with :make! or the abbreviation :mak! instead of :make, then the cursor will not jump.
vim also saves a list of places your cursor has been recently. You can jump back to your previous location with Ctrl-O, and then jump forward again with Ctrl-I Use :help jump-motions to see more about this feature.

vim :make automatically jumps to first file with error

When executing :make from vim, after make is complete it automatically jumps to a file with errors. Is there a way to avoid this
EDIT
This is usecase i want to achieve
I want :make to execute then quicklist to open but the current file which i am working on should not be switched to the one with errors
with default settings after :make execution quicklist opens and the current file also changes
From the docs:
7. If [!] is not given the first error is jumped to.
So, just invoke it as :make!.
You can run :make! | copen, which should place your cursor in the quickfix list instead of changing the current buffer. You can make this even easier by putting command Mymake make! | copen in your .vimrc, so you only have to run :Mymake to do this.
Note that when selecting errors from the quickfix list, they will scroll a buffer with the file already open rather than change the current window if possible, and you can open the files in new windows with <C-w> Enter.
It might not be the cleanest solution, but setting the errorformat to an empty string should do the trick, ie.
:set errorformat=""
That should keep it from matching the compiler error strings.

the weirdest VI problem EVER

Ok, so I am trying to type the following in .cshrc file: alias ls 'ls --color=auto'. I type one character at a tiem.
However, when I reach --color= i type a and cursor goes to the next line.
I checked the .vimrc file and didn't fine anything out of whack. I am using vim7.2
EDIT
I noticed it is only happens in the .cshrc file, and cursor starts blinking with ' character.
I had "set mouse=a" set in .vimrc file
What is the problem?
Do you have textwidth set? If so it'll break your lines once they reach a certain length. Inspect the value via
:set textwidth?
Set it to 0 to turn off hard line-wrapping. Otherwise, do you have a mapped to something weird in insert mode? Check
:imap a
to see if you do.
I cannot test it now, but probably something wrong with the appropriate indent file for that filetype. Does it happen if you edit some other configuration file ?

Resources