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
    :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.


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> new<Space>| 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.

Reply via email to