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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:46:43+00:00 2026-06-12T00:46:43+00:00

For example: I have a file longest_substring_no_repeating_chars.cc . One day I want to rename

  • 0

For example: I have a file longest_substring_no_repeating_chars.cc. One day I want to rename it to longest_substr_no_repeating_chars.cc. How do I do it by editing the old name? Or is there any convenient way to do it?

  • 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-12T00:46:45+00:00Added an answer on June 12, 2026 at 12:46 am

    Assuming you want to rename the file you’re currently editing you can define a function like this one:

    (defun rename-file-and-buffer ()
      "Renames current buffer and file it is visiting."
      (interactive)
      (let ((name (buffer-name))
            (filename (buffer-file-name)))
        (if (not (and filename (file-exists-p filename)))
            (message "Buffer '%s' is not visiting a file!" name)
          (let ((new-name (read-file-name "New name: " filename)))
            (cond ((get-buffer new-name)
                   (message "A buffer named '%s' already exists!" new-name))
                  (t
                   (rename-file name new-name 1)
                   (rename-buffer new-name)
                   (set-visited-file-name new-name)
                   (set-buffer-modified-p nil)))))))
    

    And the you can bind it to a key combo like C-c r

    (global-set-key (kbd "C-c r") 'rename-file-and-buffer)
    

    Otherwise, @Oleg’s suggestion to use dired is a great option.

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

Sidebar

Related Questions

I have a file with .php extention www.example.com/thefile.php?name=123 that I want to direct the
For example I have a file name call A.java. Here its structure: public class
I have one file (for example: test.txt), this file contains some lines and for
For example i have one .txt file, called cache.txt. It contains some information, and
I want to compress the files in ruby. for example I have file: base_1.txt
How to group two regular expression in one command example if have a file
I have example.xlsx file that contains some data. I want to show the data
I have a file containing some data (for example, 00927E2B112DB958......). This data is a
For example I have in a conf.php file: $GLOBALS[no_access] = '^forbidden|restricted|xampp|apache\_pb'; blocking these files/folders
OK. For example I have this line in my txt file: 1|1,12;7,19;6,4;8,19;2,2 As you

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.