Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit a text file in my terminal

I'm using Linux mint and using the vi command to create text files, now that I created a text file and saved it. How do I get back into to edit the text file again?

vi helloWorld.txt
like image 243
Mad_ Questionnaire Avatar asked Feb 29 '16 08:02

Mad_ Questionnaire


People also ask

How do I edit a file in terminal?

In the Terminal app on your Mac, invoke a command-line editor by typing the name of the editor, followed by a space and then the name of the file you want to open. If you want to create a new file, type the editor name, followed by a space and the pathname of the file.

How do I open and edit a file in terminal?

If you want to edit a file using terminal, press i to go into insert mode. Edit your file and press ESC and then :w to save changes and :q to quit.


2 Answers

Try this command:

sudo gedit helloWorld.txt 

it, will open up a text editor to edit your file.

OR

sudo nano helloWorld.txt 

Here, you can edit your file in the terminal window.

like image 180
Gaurav Dave Avatar answered Sep 22 '22 06:09

Gaurav Dave


Open the file again using vi. and then press " i " or press insert key ,

For save and quit

  Enter Esc     

and write the following command

  :wq 

without save and quit

  :q! 
like image 34
Nadeem Qasmi Avatar answered Sep 22 '22 06:09

Nadeem Qasmi