LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-02-2008, 07:58 AM   #1
greplinux
Member
 
Registered: Jun 2007
Posts: 118

Rep: Reputation: 17
Renaming a file in vim


Hi All,

I would like to know how to perform file renaming operations in vim, for a file which is being currently edited.
 
Old 06-02-2008, 08:40 AM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
:w another_name
 
Old 06-02-2008, 08:44 AM   #3
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
This came from the help inside vim.
Code:
Renaming files                                          *rename-files*

Say I have a directory with the following files in them (directory picked at
random :-):

buffer.c
charset.c
digraph.c
...

and I want to rename *.c *.bla.  I'd do it like this: >

        $ vim
        :r !ls *.c
        :%s/\(.*\).c/mv & \1.bla
        :w !sh
        :q!
You invoke the help within vim by entering the colon then typing help.

Last edited by stress_junkie; 06-02-2008 at 08:46 AM.
 
Old 06-04-2008, 03:44 AM   #4
greplinux
Member
 
Registered: Jun 2007
Posts: 118

Original Poster
Rep: Reputation: 17
Hi Guys,

Thanks for answering. Anyhow i am not able to demonstrate what "tress junkie" suggested. And what Agrouf said is like 'save as ' and not renaming.
 
Old 06-04-2008, 06:33 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
In short I don't think you can rename a file you have open in an editor. Either use Afgrouf's suggestion, or exit and rename.
 
Old 06-06-2008, 10:34 AM   #6
greplinux
Member
 
Registered: Jun 2007
Posts: 118

Original Poster
Rep: Reputation: 17
Thanks Chris.
 
Old 11-27-2008, 05:39 AM   #7
dummytaurus
LQ Newbie
 
Registered: Nov 2008
Posts: 2

Rep: Reputation: 0
I got the same problem
 
Old 11-27-2008, 05:40 AM   #8
dummytaurus
LQ Newbie
 
Registered: Nov 2008
Posts: 2

Rep: Reputation: 0
You should check http://www.infynity.spodzone.com/vim/Rename.vim
 
Old 11-27-2008, 12:02 PM   #9
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
Vim is an editor, not a file manager, so it's not supposed to do renaming, although there probably are way of doing that. (Versatility of Linux)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
file renaming computer_tom Linux - General 3 02-18-2008 12:27 PM
File Renaming Query johnpaulodonnell Linux - Newbie 5 11-07-2006 10:08 AM
File renaming amushtaq Linux - Software 2 01-13-2006 05:40 AM
renaming a file?? U-Toast Linux - Newbie 2 08-29-2004 01:07 AM
renaming or converting a text file to a dat file... tangaz Linux - Software 1 10-24-2003 06:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration