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 8032139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:18:21+00:00 2026-06-05T01:18:21+00:00

Is there a way to move a file within Vim? E.g. I opened a

  • 0

Is there a way to move a file within Vim? E.g. I opened a file foo/bar.txt in Vim. I know 2 ways to move this file:

First solution:

  1. Delete the buffer with :bd bar.txt
  2. Perform the move on the shell with mv foo/bar.txt foo/bar2.txt
  3. Load the file in vim with :e foo/bar2.txt

Second solution:

  1. Close Vim, so all buffer where closed.
  2. Perform the move on the shell…
  3. Start Vim and load the file.

But these two solutions are embarrassing. I know, there is a plugin for renaming files vim-enuch, but isn’t there a Vim way for performing such basic functionality?

  • 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-06-05T01:18:24+00:00Added an answer on June 5, 2026 at 1:18 am

    There is no atomic way to move a file like that, but this should be close:

    function! MoveFile(newspec)
         let old = expand('%')
         " could be improved:
         if (old == a:newspec)
             return 0
         endif
         exe 'sav' fnameescape(a:newspec)
         call delete(old)
    endfunction
    
    command! -nargs=1 -complete=file -bar MoveFile call MoveFile('<args>')
    

    Now you could say:

    :MoveFile file2.txt
    

    To rename to file2.txt

    :MoveFile %.0
    

    to move file2.txt to file2.txt.0

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

Sidebar

Related Questions

Is there a way to move an item of say id=10 as the first
I hope to know if there is a way to move row to the
Is there any way to know for events when move a window with window.open?.
Is there a simpler way of reordering methods within a class source file in
I would like to know if there's a way to move a project in
is there a way to move the data from an excel sheet to a
Is there a way to move a sequential set of commits from one (local)
Is there a way to move the content from a std::string into a std::vector?
Is there a way to allow a move constructor and disallow copy construction and
Is there a way I can programatically move my screens in relation to each

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.