RE: creating a new file in the Explorer

2006-07-28 Thread Carlos Beltran


Uhmm. It would be nice also to be able to rename files.

Carlos.


 -Original Message-
 From: Roel Vanhout [mailto:[EMAIL PROTECTED]
 Sent: Friday, July 28, 2006 2:38 PM
 To: vim@vim.org
 Subject: creating a new file in the Explorer
 
 Hi,
 
 In the vim Explorer (:Explore), I can create a new directory by pressing
 'd' and typing the directoryname. Is there something similar for
 creating a new, empty file? I've looked through the documentation but
 couldn't find anything. I now press 'c' and type :new filename, but
 that's error-prone (I usually forget to press 'c' and end up with a file
 in the wrong directory). Thanks.
 
 cheers,
 
 roel




Re: creating a new file in the Explorer

2006-07-28 Thread A.J.Mechelynck

Roel Vanhout wrote:

Hi,

In the vim Explorer (:Explore), I can create a new directory by pressing 
'd' and typing the directoryname. Is there something similar for 
creating a new, empty file? I've looked through the documentation but 
couldn't find anything. I now press 'c' and type :new filename, but 
that's error-prone (I usually forget to press 'c' and end up with a file 
in the wrong directory). Thanks.


cheers,

roel






:mapF2  :cd %:p:h Bar newSpace

will allow you to open a new file in the currently browsed directory, 
or, if currently not browsing a directory, in the same directory as the 
current file. (Replace F2 by any other shortcut key you want to use.) 
The cursor ends up on the command line, ready for you to enter the 
filename. Hit Enter without a filename to open a [No Name] buffer; hit 
Esc to cancel.


The current dir is set to the dir being browsed (or to the dir of the 
current file) as a side-effect.


If there already is a file or subdirectory by the name you give, you end 
up editing that file (or browsing that subdirectory) in a new split window.



Best regards,
Tony.


Re: creating a new file in the Explorer

2006-07-28 Thread Roel Vanhout

A.J.Mechelynck wrote:
In the vim Explorer (:Explore), I can create a new directory by 
pressing 'd' and typing the directoryname. Is there something similar 
for creating a new, empty file? I've looked through the documentation 

:mapF2:cd %:p:h Bar newSpace
will allow you to open a new file in the currently browsed directory, 
or, if currently not browsing a directory, in the same directory as the 
current file. (Replace F2 by any other shortcut key you want to use.) 
The cursor ends up on the command line, ready for you to enter the 
filename. Hit Enter without a filename to open a [No Name] buffer; hit 
Esc to cancel.



This is great, thanks. Is there also a way to make this work only in the 
Explorer window/mode?



cheers,

roel


Re: creating a new file in the Explorer

2006-07-28 Thread Charles E Campbell Jr

Roel Vanhout wrote:

In the vim Explorer (:Explore), I can create a new directory by 
pressing 'd' and typing the directoryname. Is there something similar 
for creating a new, empty file? I've looked through the documentation 
but couldn't find anything. I now press 'c' and type :new filename, 
but that's error-prone (I usually forget to press 'c' and end up with 
a file in the wrong directory). Thanks.


Have you considered having
 let g:netrw_keepdir= 0
in your .vimrc?  That way the current directory (:pwd) will track what 
netrw uses for the current directory, and so creating a new empty file 
(:enew, for example) will be made in the directory you're expecting.


Regards,
Chip Campbell



Re: creating a new file in the Explorer

2006-07-28 Thread Charles E Campbell Jr

Carlos Beltran wrote:


Uhmm. It would be nice also to be able to rename files.
 


:he netrw-R

Regards,
Chip Campbell



Re: creating a new file in the Explorer

2006-07-28 Thread A.J.Mechelynck

Roel Vanhout wrote:

A.J.Mechelynck wrote:
In the vim Explorer (:Explore), I can create a new directory by 
pressing 'd' and typing the directoryname. Is there something similar 
for creating a new, empty file? I've looked through the documentation 

:mapF2:cd %:p:h Bar newSpace
will allow you to open a new file in the currently browsed directory, 
or, if currently not browsing a directory, in the same directory as 
the current file. (Replace F2 by any other shortcut key you want to 
use.) The cursor ends up on the command line, ready for you to enter 
the filename. Hit Enter without a filename to open a [No Name] 
buffer; hit Esc to cancel.



This is great, thanks. Is there also a way to make this work only in the 
Explorer window/mode?



cheers,

roel




Maybe, but I doubt if it's worth it. Maybe something like (untested)

  :au BufNew * if isdirectory(amatch) |  map buffer F2 :cd %:p:h 
Bar newSpace| endif


which must be typed all on one line.


In that previous post, I had tried to create a mapping that would give 
useful results even if used outside the netrw (Explorer) window.



Best regards,
Tony.