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

  • Home
  • SEARCH
  • 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 6949969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:01:48+00:00 2026-05-27T14:01:48+00:00

I wrote a function to get the full path of the current file under

  • 0

I wrote a function to get the full path of the current file under the cursor

nmap <F12> :echo GetFullPath()<cr>
function! GetFullPath()
    let currentFile=expand("<cfile>")
    let afterChangeSlash=substitute(currentFile,"/","\\","g")
    let fullPath="e:\\Test\\".afterChangeSlash
    return fullPath
endfunction

When I call the function after the :echo command, I get the expected result,like:

:echo GetFullPath()

e:\Test\test.h

However,When I call it after the :e(edit) command:

:e GetFullPath()

Vim just create a new file named GetFullPath()

Why the command :e will treat a function call literally while the command :echo won’t?

  • 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-27T14:01:49+00:00Added an answer on May 27, 2026 at 2:01 pm

    You can use :execute to build your ex command string and execute it:

    :exe "e ".GetFullPath()
    

    Or use the `=` syntax to expand a Vim expression:

    :e `=GetFullPath()`
    

    If you check the help for :edit and :echo, you’ll notice that the former expects its argument to be the file name (literally), while :echo expects an expression which will be evaluated.

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

Sidebar

Related Questions

I wrote this function to get the unread count of google reader items. function
I wrote this function to get a pseudo random float between 0 .. 1
I need to get the full path from a PID. I've checked this question
I am trying to write a function to get a list of offers (their
I use the NSHomeDirectory() function to get the app's home folder, and write to
i want to create functions what get the folder size. I write small function:
I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000" .
I wrote this function for filling closed loop, pixvali is declared globally to store
I wrote a function in bash script. However, it's complaining about syntax. I really
I wrote a function to match fingerprint templates using VC++.NET. Now I want to

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.