Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between ':source file' and ':runtime file' in vim?

Tags:

I saw this command in the /etc/vimrc file on my system:

runtime! vimrc_example.vim 

From the docs:

:ru[ntime][!] {file} .. Read Ex commands from {file} in each directory given by 'runtimepath'.

Is it otherwise equivalent to :source {file}?

like image 935
Eugene Yarmash Avatar asked Sep 06 '11 13:09

Eugene Yarmash


People also ask

What does source mean in Vim?

Sourcing a file is 'executing' it. Essentially, each line of the file is considered a command. Sourcing it is the same as typing each command in order. You source with the command :source (usually shortened to :so ). So if you source myStuff.vim :so myStuff.vim.

What is runtime path in Vim?

The Runtime Path. The runtime path is similar to the environment variable PATH in Unix-based systems. Vim will search in these paths to locate and source many different files during startup. To see all of these paths, you can look at the value of the option runtimepath , by running the command :set runtimepath? .

Is vim a text file?

Vim is a text editor to create or edit a text file, config file and programs on a Linux, macOS, and Unix-like system.


1 Answers

:source sources the file specified by the path given (relative or absolute)

:runtime sources the first file (unless banged!) found in &runtimepath that matches the partial path given.

BTW, the pathnames used with :runtime can contain wildchars (somehow a glob-pattern). This has nothing to do with regexes.

like image 86
Luc Hermitte Avatar answered Oct 14 '22 08:10

Luc Hermitte