Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create file inside new directory in vim in one step?

Tags:

While in vim I want to create a new file called blog_spec.rb inside [working directory]/spec/models/, but the directory doesn't exist yet?

What's the fastest way to create the directory and start editing the file? Any oneliners?

like image 711
Christian Schlensker Avatar asked May 01 '12 07:05

Christian Schlensker


People also ask

How do I create a file in a directory?

You can either click the Terminal icon in the Apps menu, or press Ctrl + Alt + T at the same time to open the Terminal. Navigate to the directory you want to create a file in. To do so, type cd followed by the path to the directory you want to create a file in and press Enter..

How do you create a file in NERDTree?

Press m to bring up the NERDTree Filesystem Menu. This menu allows you to create, rename, and delete files and directories. Type a to add a child node and then simply enter the filename. You're done!


1 Answers

:!mkdir -p spec/models :w spec/models/blog_spec.rb 
like image 194
Kelly Avatar answered Oct 13 '22 23:10

Kelly