LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 08: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, 09:40 AM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
:w another_name
 
Old 06-02-2008, 09: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: 331Reputation: 331Reputation: 331Reputation: 331
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 09:46 AM.
 
Old 06-04-2008, 04: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, 07:33 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
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, 11:34 AM   #6
greplinux
Member
 
Registered: Jun 2007
Posts: 118

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

Rep: Reputation: 0
I got the same problem
 
Old 11-27-2008, 06: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, 01: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:27 PM
File Renaming Query johnpaulodonnell Linux - Newbie 5 11-07-2006 11:08 AM
File renaming amushtaq Linux - Software 2 01-13-2006 06:40 AM
renaming a file?? U-Toast Linux - Newbie 2 08-29-2004 02:07 AM
renaming or converting a text file to a dat file... tangaz Linux - Software 1 10-24-2003 07:57 AM


All times are GMT -5. The time now is 09:05 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration