7

How do I resolve this error:

E499: Empty file name for '%' or '#', only works with ":p:h"

This error happens anytime I use % in a vim command. I've never seen this before. Here is my .vimrc:

set nocompatible
filetype off

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
"Plugin 'scrooloose/nerdtree'
"Plugin 'bling/vim-airline'
"Plugin 'altercation/vim-colors-solarized'

call vundle#end()
filetype plugin indent on

I've commented out those last few plugins to see if they had any correlation with the error, but that didn't seem to help. I used Git to install vim as usual:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

All I did after that was run :PluginInstall to install the plugins, and then ran :source % which gave the error.

OS: Ubuntu 15.04

2 Answers 2

5

This seems to be related to an empty %. You can do two things: pass the filename when invoking vim: vim myscript.vim and then calling :source %, or passing the filename to :source (:source myscript.vim).

Per the docs, :help registers lists % as a read-only register containing the current filename. So, if you are editing a buffer that doesn't have a filename (not saved), this % register is empty, resulting in the error message that you are getting.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the response, however I am having another issue that I will try to resolve on my own, and update here if I can't figure it out. Also running into quite a few unrelated problems on this install of Ubuntu, many file permission and configuration errors.
1

This error is displayed when :source % is used after opening vim without any files. What you could do is open vim with a file name e.g. vim file1.js , and then try :source %

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.