Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 648237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:48:36+00:00 2026-05-13T21:48:36+00:00

I am editing a file like /path/to/file.txt with vim, hence the current directory is

  • 0

I am editing a file like
/path/to/file.txt
with vim, hence the current directory is
/path/to.

Now, I have a directory
/other/path/to/vim/files
that contains sourceA.vim. Also, there is a sourceB.vim file in
/other/path/to/vim/files/lib/sourceB.vim

In sourceA.vim, I want to source sourceB.vim, so I put a
so lib/sourceB.vim
into it.

Now, in my file.txt, I do a
:so /other/path/to/vim/files/sourceA.vim
which fails, because the sourcing system is obviously not prepared for relative path names along with sourcing from another directory.

In order to fix this, I put a
execute "so " . expand("<sfile>:p:h") . "/lib/sourceB.vim"
into sourceA.vim which does what I want.

However, I find the solution a bit clumsy and was wondering if there is a more elegant solution to it.

I cannot put the sourceA.vim nor sourceB.vim into vim’s plugin folder.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:48:36+00:00Added an answer on May 13, 2026 at 9:48 pm

    Maybe you could modify your runtimepath in your vimrc or elsewhere:

    set runtimepath+=/other/path/to/vim/files
    

    Then use :runtime instead of :source in your sourceA.vim file:

    runtime lib/sourceB.vim
    

    You can then use the same “:so /../../../sourceA.vim” command as before…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In particular, I'm editing the AutoCompletion.plist file for CSSEdit (if that even matters). My
While editing an aspx file I found both these opening tags used for seemingly
When editing an XML file in IntelliJ IDEA, if the document references a schema,
I'm in Visual Studio 2008, and I'm editing a CSS file. I use ctrl+f
I want to add a row of headers to an existing CSV file, editing
How can I programmatically lock/unlock, or otherwise prevent/enable editing, a source file on Linux
Sometimes when I'm editing page or control the .designer files stop being updated with
Often while editing config files, I'll open one with vi and then when I
When editing XAML in VS2008 SP1, the editor is really slow. devenv process seems
When editing HTML in emacs, is there a way to automatically pretty-format a blob

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.