How can I create a file adjacent to the one I'm editing in Vim? If I'm editing ./app/lib/foo.js I want to create ./app/lib/bar.js
|
If the name of the new file is easy to type, Oliver Salzburg's answer is probably best. If the name of the new file differs only slightly from the name of the current file, it may be easier to use
where
|
|||
|
|
|
Given the information on the VIM wiki:
|
|||||||
|
|
One way I like to create files is using the Explore window. Open the Explore window:
Now to create a new file in the current directory press %, it will ask for a file name and then open the new file (actually the file will not be created until you write it). |
|||
|
|
|
Just "open" the new file as if it already existed, like so:
Or, if bar.js is going to be very similar to foo.js, you could copy foo.js into bar.js like so:
To create an empty foo.js file, just "touch" it like this:
|
|||
|