I want to create a text file and open it in a text editor with a single command.
I know touch file.txt
creates a file and open file.txt
opens the file, but is there a way to do this with a single command?
I want to create a text file and open it in a text editor with a single command. I know |
||||
|
You could use |
|||||
|
If you are looking for some logic for this, ie. create a file and open if possible you could use something like this:
Here testFile is created with touch. The Also, you could just create a new file with something like vi, while opening it at the same time (this assumes you save the file after editing it).
|
|||
|
That entirely depends on your text editor. Most will allow you to simply open a non-existent file, and assume you want it created on save. You could also use a function if that is somehow not possible for you:
You can call it as |
||||
|
Use vim. Just type
For vim you need to know the hot-keys.
or (Easier to use
If you want a GUI type: (Works for ubuntu and other distros)
|
|||
Like everyone is telling you, this depends on your editor. And if you don't like the way your editor handles this, that can probably be configured, as well. With Emacs, While this is certainly one way, I think an even better way is to always have an instance of Emacs running. So, whenever you feel the need for a new file, go to Emacs, hit |
|||
|