Vim ": source%" results in an error (E499)

Greetings to Stum Overflow vim users. I recently discovered that I spent a significant amount of time in my computer book, Computer Science Lab. I have configured vim on countless linux systems and have never encountered this error:

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

This error occurs when I use% in a command in vim. I have never seen this before, but I will give as much information as possible. 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 commented on these last few plugins to see if they were related to a bug, 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: PluginInstall to install the plugins, and then tried to use: source%, which led to an error.

This really puzzled me, and I hope to solve it, since I would like to use a customized vim setting for this CS class, but I can deal with a stock of ViM or even Vi, or if that happens ... nano.

EDIT: Using Ubuntu 15.04

+5
source share
1 answer

This seems to be due to empty % . You can do two things: pass the file name when calling vim: vim myscript.vim , and then call :source % or pass the file name to :source ( :source myscript.vim ).

EDIT

If you issue :help registers , the list indicates that % is a read-only register containing the current file name. So, if you are editing a buffer that does not have a file name (it is not saved), this register is empty and you will receive an error message.

+1
source

Source: https://habr.com/ru/post/1242014/


All Articles