Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I source files relative to file?

Tags:

vim

neovim

I'm trying to split my vimrc up into multiple files - init.vim, keybindings.vim, ui.vim, etc. - but I can't get Vim to source files relative to init.vim (it instead sources relative to where I launch Vim from.

This is what I've got at the top of init.vim:

source keybindings.vim
source ui.vim

If I run vim from the same directory as those files, it works fine; if I run it from any other directory, I get the following errors:

Error detected while processing /path/to/vimrc:
line 1:
E484: Can't open file keybindings.vim
line 2:
E484: Can't open file ui.vim
Press ENTER or type command to continue

Edit: It's worth noting that I'm using NixOS, so I don't know what the absolute paths will be, nor if they would be constant if I found out.

like image 431
ahstro Avatar asked Oct 26 '17 21:10

ahstro


1 Answers

I think you can use

runtime keybindings.vim
like image 80
dave Avatar answered Nov 14 '22 17:11

dave