Unable to edit using vi

52,082

Solution 1

You are doing nothing wrong. You just don't know how to use vim.

Vim is an editor that works differently from any other editor. If you want to understand how it works, open a terminal in full screen and type vimtutor. It will teach you how to use vim inside vim.

Solution 2

If you're dissatisfied with the complexities of using vi, try using nano text editor, which is included in the default Ubuntu installation. There are only two things that you need to know to use nano, and they both appear at the bottom of every page in nano. The only two nano keyboard shortcuts that you need to know are for WriteOut and Exit.

  • Press the keyboard combination Ctrl+O and after that press Enter to save the file being edited in nano to its current location.

  • Press the keyboard combination Ctrl+X to exit nano.

To edit the /etc/network/interfaces file from the terminal type:

sudo nano /etc/network/interfaces  
Share:
52,082

Related videos on Youtube

user235801
Author by

user235801

Updated on September 18, 2022

Comments

  • user235801
    user235801 over 1 year

    I'm trying to edit my /etc/network/interfaces file to add a line for a proxy server. I first "sudo su -" to be root, and then "vi /etc/network/interfaces". But once I'm in there, I'm unable to edit. I've tried hitting both "insert" and "i" on my keyboard, which should work for vi. What gives? And what am I doing wrong?

    • gertvdijk
      gertvdijk over 10 years
      "I'm unable to edit" So what happens instead when you start typing? Do you see something in the bottom of the terminal window? Please be a bit more descriptive as we can't see your screen we rely on the information in your question.
    • BlitZz
      BlitZz over 10 years
      also, try sudo vi /etc/network/interfaces. You'll type less :)
    • Warren Hill
      Warren Hill over 10 years
      have you tried another editor such as nano. sudo nano /etc/network/interfaces should work and nano is a more intuitive editor to use. If you particularly want to use vi you will need to provide more details.
    • mreq
      mreq over 10 years
      @roadmr sudoedit /etc/network/interfaces even better :)
    • Panther
      Panther over 10 years
      @roadmr sudo -e /etc/network/interfaces, even less typing =)
    • Panther
      Panther over 10 years
      By default, ubuntu has vim-tiny installed. If you use vim, I suggest you simply install vim sudo apt-get install vim vim-scripts vim-doc vim-latexsuite vim-gui-common vim-gnome
    • Rmano
      Rmano over 10 years
      A lot of people (including myself since relatively short ago) is unable to edit using vi... :-). Jokes aside, I concur that for casual use better resort to nano. Being root and trying to learn vi together is a really, really dangerous thing to do.
  • falconer
    falconer over 10 years
    Just a note: If he just wants to use nano for fast editing a system file then CTRL+X is enough to remember as it will ask whether he wants to save the file. If he wants to do just a little bit more serious editing then he will definitely need to switch to a more powerful editor, as nano lacks even an undo functionality. (Okay there is experimental support if you start with nano -u ...)