73

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
Mad_ Questionnaire
  • 843
  • 3
  • 10
  • 11

6 Answers6

87

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.

Gaurav Dave
  • 6,838
  • 9
  • 25
  • 39
50

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!
Husam
  • 8,149
  • 3
  • 38
  • 45
Nadeem Qasmi
  • 2,217
  • 22
  • 16
34

Open the file again using vi. and then press the insert button to begin editing it.

Arpit Aggarwal
  • 841
  • 8
  • 18
5

If you are still inside the vi editor, you might be in a different mode from the one you want. Hit ESC a couple of times (until it rings or flashes) and then "i" to enter INSERT mode or "a" to enter APPEND mode (they are the same, just start before or after current character).

If you are back at the command prompt, make sure you can locate the file, then navigate to that directory and perform the mentioned "vi helloWorld.txt". Once you are in the editor, you'll need to check the vi reference to know how to perform the editions you want (you may want to google "vi reference" or "vi cheat sheet").

Once the edition is done, hit ESC again, then type :wq to save your work or :q! to quit without saving.

For quick reference, here you have a text-based cheat sheet.

manuelvigarcia
  • 1,696
  • 1
  • 22
  • 32
1

You can open the file again using vi helloworld.txt and then use cat /path/your_file to view it.

-4

you doesn't have root access type this

sudo su

If you want to use nano editor to create file in same directory where you headed

  1. nano filename.format

eg:- nano attendaence.txt

  1. Ctrl+o

  2. Enter
    
  3. Ctrl+x
    

If you want to use nano editor to create file in other directory where you headed

  1. nano location/filename.txt
    

eg1:- nano home/ec2-user/public_html/attendence.php

eg2:- nano /home/ec2-user/public_html/attendence.php 2. Ctrl+o 3. Enter 4. Ctrl+x

Create file without editor in same directory

touch filename.format

eg:- touch helloworld.html Create file without editor in another directory

touch location/filename.format

eg:- touch var/www/index.html

Ronny Dsouza
  • 358
  • 2
  • 12
  • As I'm one of three persons to downvote this - First - I found this didn't seem to address the original question Second- and more importantly - you are for some reason suggesting that that user become root/super-user. 'sudo su' will open up more problems, and isn't necessary for this, and you don't suggest why the questioner might do so. Lots of unconnected facts, but no good answer, and at least one troublesome piece of advice. (Maybe you might revise this response?) – Pete Kelley Feb 23 '23 at 18:46