Skip to content
← Back to Community
Open a file in code editor from shell
Profile icon
SMShimanto

I'm looking for a command that will open a file in the editor tab. If the file does not exist it should create the file.
As we see in VScode "code filename" command.
[Edit]
My main goal is to use the shell instead of the left file explorer provided by repl.it
Thanks

Voters
Profile icon
hcl10616
Profile icon
BradCodeCoach
Profile icon
SMShimanto
Comments
hotnewtop
Profile icon
Codeverse

I couldn't find a command to do so, but I know a program that comes close to it. First do this, npm init, then npm i nedb. Second,

const Datastore = require('nedb'); const database = new Datastore('database.db'); database.loadDatabase(); //database.db can be changed but must have .db at the end.
Profile icon
Squirrel777

Well, there is no command to do both! But the shell in your repl is bash, which does not have the code command like Windows. So to create a file do touch <example.txt> and to open a file do cd path/to/file/name and you are done!

Profile icon
SMShimanto

@Squirrel777 cd command can't open a file instead of folder

Profile icon
Wumi4

You can use the CLI text editors, like Vim, Emacs, Neovim, Kakoune, etc.

Profile icon
SMShimanto

@Wumi4 Thanks but I want to use the main code editor provided by repl.it

Profile icon
Wumi4

@SMShimanto Then just click on the file, it should appear on the File Browser on the left of your editor.

Profile icon
SMShimanto

@Wumi4 yes that works but I want it to be done by my python programmer