Edit Page
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 3: | Line 3: | ||
|previous=1526 |
|previous=1526 |
||
|next=1530 |
|next=1530 |
||
− | |created=2007 |
+ | |created=November 8, 2007 |
|complexity=intermediate |
|complexity=intermediate |
||
|author= |
|author= |
||
Line 11: | Line 11: | ||
|category2= |
|category2= |
||
}} |
}} |
||
− | When opening a new file with < |
+ | When opening a new file with <tt>:edit</tt> or <tt>:split</tt>, you may want to create the directory the file will reside in. This can be done in autocommand BufNewFile (add to [[vimrc]] in any Unix-like system with mkdir that accepts -p switch). |
<pre> |
<pre> |
||
au BufNewFile * :exe ': !mkdir -p ' . escape(fnamemodify(bufname('%'),':p:h'),'#% \\') |
au BufNewFile * :exe ': !mkdir -p ' . escape(fnamemodify(bufname('%'),':p:h'),'#% \\') |
||
Line 18: | Line 18: | ||
==Comments== |
==Comments== |
||
{{Todo}} |
{{Todo}} |
||
− | This tip is rather dodgy for those of us who sometimes make mistakes. I don't think it should automatically create possibly several directories as a result of a simple typo in the < |
+ | This tip is rather dodgy for those of us who sometimes make mistakes. I don't think it should automatically create possibly several directories as a result of a simple typo in the <tt>:edit /path/file</tt> command. |
The tip should instead provide a specific command to create a path and edit a file (you would know that using the command may create unwanted directories if you made a typo). |
The tip should instead provide a specific command to create a path and edit a file (you would know that using the command may create unwanted directories if you made a typo). |
||
− | I believe that the md/mkdir in any Windows with cmd.exe (possibly not NT4) will make intermediate directories without needing < |
+ | I believe that the md/mkdir in any Windows with cmd.exe (possibly not NT4) will make intermediate directories without needing <tt>-p</tt> or any other option. |
---- |
---- |