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





        :map    <F2>      :cd %:p:h <Bar> new<Space>

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.

Reply via email to