Hot answers tagged

43 votes
Accepted

What does `<Bar>` mean?

It's the code for the pipe character: |. The pipe is used the way the semicolon is used in C-style languages, as a statement separator. You cannot use it directly in a mapping, since it would be seen ...
  • 24k
29 votes
Accepted

Why am I getting a "E488: Trailing characters" error on this custom command?

Remove the trailing <cr> That is only needed for mappings, but not for commands.
23 votes
Accepted

BufWinLeave * mkview with unnamed file: Error 32

Switching to ?* as the regex will no longer match empty file names. I actually recommend you switch to the following, which is a corresponding block of .vimrc that has been tweaked to suppress many of ...
12 votes
Accepted

`E575: viminfo: Illegal starting char in line: ...` on startup

Turns out the answer was in the error message all along.. the offending file was ~/.viminfo which was somehow corrupted.
9 votes
Accepted

How can I stop Vim from writing a file without throwing an error?

Instead of using the BufWritePre autocmd, you can use the BufWriteCmd autocmd, from :help BufWriteCmd: Should do the writing of the file and reset 'modified' if successful, unless '+' is in 'cpo' ...
8 votes
Accepted

How to cut/trim line in statusline?

Values used in :set are strings. See :h set-args: :set-args E487 E521 :se[t] {option}={value} or :se[t] {option}:{value} ...
  • 24k
8 votes
Accepted

When should a function *not* be defined with "abort"

Discl.: It's just guessing on my part. abort didn't exist when function was introduced. I guess that in order to not break existing code it was decided to not change the current behaviour and to ...
  • 16.2k
8 votes
Accepted

In Linux, on an extremely long running vim session, calls to system() fail with E484 "can't open file /tmp/<tempfile>"

This happens when some system cron job cleans out "unused" files from /tmp. The solutions are: Find that cron job and stop it from rm'ing your Vim /tmp files. Recreate Vim's temporary directory. ...
  • 5,964
7 votes

How do I open file under cursor, when the filename has a trailing dot?

From :help gf: Trailing punctuation characters ".,:;!" are ignored. So I suppose the dot at the end is not considered as part of the filename but as punctuation. I don't know if it can be done with ...
  • 6,506
7 votes
Accepted

Why do I get an E488 error when printf .vimrc?

# is not a comment character, " is. So it should read: " Funcionar como vim y no como vi set nocompatible " Colorear sintaxis syntax on colorscheme sienna " Otros seteos " Más info, desde vim poner:...
7 votes
Accepted

Print an error message without "Error detected while processing function"

The solution is described in the manual: If you just want a highlighted message use :echohl. And to get a beep: :exe "normal \<Esc>" Thus: function! PrintError(msg) abort execute '...
  • 3,889
6 votes
Accepted

regex: how to replace "\["?

I found the reason: [ is special character so vim treats next characters as part of the set ([...]) although it doesn't have the closing bracket. The proper replace should be: :s/\\\[//g (One ...
  • 1,538
6 votes

What does `<Bar>` mean?

If you type :help <Bar> you will read that <Bar> vertical bar | 124 <Bar>
  • 161
5 votes
Accepted

E334: Menu not found: Window.Minimize

Important note As I mentioned it in the comments when you begin to use Vim the best you can do is to start with an emtpy .vimrc. From this you'll be able to build your own configuration which really ...
  • 46.8k
5 votes
Accepted

Why I'm getting Invalid arguments for the function when using double-quotes?

From :help :put: The register can also be = followed by an optional expression. The expression continues until the end of the command. You need to escape the | and " characters to prevent them ...
  • 33.3k
5 votes

What does `<Bar>` mean?

I'd like to add that in normal mode, the | command (which has to be substituted with <bar>, \| or ^V| while remapping it, as mentioned in other answers) allows you to go to a specific screen ...
  • 151
5 votes
Accepted

Absolute script-file line-numbers in Vim-function errors

There was an RFC suggesting this, but there was no response from Bram at the time.
  • 10.4k
4 votes

Can't change directory to network drive

This was a bug, that was fixed in 7.4.096. (You didn't specify exact version, so I assume, you are using plain 7.4 version and I used to have the same problem when cding into a UNC path)
4 votes
Accepted

c:\Program is not recognized error while running vimdiff

Getting a fixed Vim This specific bug was fixed in 7.4.103 back in 2013. Bram typically only publishes Windows installers on vim.org for major releases, so the installer there doesn't have this fix. ...
  • 10.4k
4 votes
Accepted

How do I open file under cursor, when the filename has a trailing dot?

Another option is to set includeexpr. From :help includeexpr: *'includeexpr'* *'inex'* 'includeexpr' 'inex' string (default "") ...
  • 455
4 votes

Don't fail if pattern is not found

Here's a mapping that won't change the last search register or print errors: nnoremap <expr> ]m filter([search('pattern', 'nW'), line('.')], 'v:val')[0].'G' filter() takes a list of items and ...
  • 6,420
4 votes
Accepted

Delay with remapped q

This happens because Vim waits to see if you want to do q<letter> to start recording a macro (there are a couple other things too like q:). You can use the tm option to change the amount it ...
  • 216
4 votes

How can I suppress startup error E575?

Check your init.vim. If there is any line concerning viminfo, temporarily remove/comment it, you can later discover the reason it messed up. Then backup and remove ~/.local/share/nvim/shada folder. ...
  • 3,341
4 votes
Accepted

Why do I get "incompatible error" while opening .sh files using vi in cygwin?

The option name is nocompatible. Replace incompatible with nocompatible to solve your problem.
  • 21.8k
4 votes
Accepted

Difference between make and make!

This is happening because while :make! doesn't jump to the first error message, it actually sets the quickfix cursor at it. So when you use :cnext it will actually try to go to the second error, which ...
  • 26.5k
3 votes
Accepted

Why Error E172 on Execution?

You need to escape the line so that tabedit /Users/masi/Raspberry Pi/me-hello-yes.tex becomes tabedit /Users/masi/Raspberry\ Pi/me-hello-yes.tex Otherwise, tabedit sees two filenames /Users/masi/...
  • 15.3k
3 votes
Accepted

vim-autoformat plugin - undefined shiftwidth function

shiftwidth() is a function that has been added I think late in the 7.3 circle. Can you update your Vim version?
3 votes

`E575: viminfo: Illegal starting char in line: ...` on startup

For me, this problem keeps showing up even if I delete the ~/.viminfo file - not right away, but a couple of days later. I just noticed there's a way to skip using the viminfo file entirely, as ...
3 votes

Scroll buffer-window whilst Ex-log open

Vim stores up to 20 error messages by default in its messages history. This list can be reviewed using the command :messages. For further information check: :help :messages :help 'shortmess'
  • 1,572
3 votes
Accepted

Scroll buffer-window whilst Ex-log open

I don't believe it's possible to scroll the buffer while the Ex-command output is displaying. A workaround is to redirect the output to a new file, which you can then open in a split. :redir > ...
  • 28.9k

Only top scored, non community-wiki answers of a minimum length are eligible