Ubuntu Text Editors

I remember the first time that I used an Ubuntu text editor.

It was during a simpler time when I was some how developing on a Windows machine.

I was trying to debug and fix multiple PHP scripts using vi. I still have nightmares to this day about that.

This week, I was reminded of this pain by a fellow colleague who came to me after experiencing the same pain.

I have no idea why vi was designed the way it was. So you open a file up with it (making sure you do it with “sudo”, otherwise everything you do would be for nothing).

Then you move your cursor to the right place and start typing. Nothing happens.

Oh of course, you have to press “a” first, and then you can type what you like. How obvious is that?!

OK, I now want to move to a different line. I am still in “insert mode” because I have not finished typing. In true terminal tradition, I begin using the arrow keys to move my cursor…

What the….

The joys of Vi

Letters are appearing!!

When I press the arrows,  the cursor moves and puts a letter in place. One of 4 depending which arrow I press. Why??? What was the design decision behind this to make it do this?!?! It just makes no sense! It is not like I don’t have 26 other keys which are dedicated to typing letters!

To move, I have to remember to press Esc, to get out of “insert mode”, then press the arrows, then press “a” again.

What about saving. Well obviously, you type a colon to do a command, followed by a letter; and obviously the letter of choice for saving is “w” (I guess, on hindsight, w means write).

But wait!

What does this even mean?! It only appears sometimes! It is so spontaneous that I have gotten into the habit of adding the ! every time.

I have since gotten used to the commands of vi. But I will never be able to understand the logic behind having letters appear when I press arrows. It is so ridiculous!

Luckily, there is a solution that fixes this. It is called vim.

Simply run: apt-get install vim and it will automatically install and be used instead of vi.

It still has the same commands as vi, and you can still use it as if you are using vi (sudo vi text.txt).

It comes with two improvements:

  1. It fixes the stupid design flaw of not being able to use the arrow keys whilst in insert mode.
  2. It adds colours to the code to make it a little bit more readable.

In my opinion vim is how vi should have been to begin with. I have gotten very used it to it and always use it when I want to quickly edit, say, a config file, for example. Unfortunately, it is not always installed on every server and vi comes to haunt me.

If vim is still not easy enough for you, you can always use nano.

Nano is as close to a GUI text editor as you are going to get in terminal.

Just do apt-get install nano and then say sudo nano text.txt to use (Note: it does not automatically override vi like vim does).

Then just start typing as you would in a text editor! No pressing keys to begin typing or stop typing. No weird behaviour when you press the arrow keys.

All the commands you need are helpfully listed at the bottom. Note that the ^ actually means Ctrl. So CTRL+O will save it. But you will be given the option to change the name of the file (no random need for exclamation marks either!).

Finally, you have gedit.

People who use the desktop edition of Ubuntu will be very familiar with this one. It is the text editor you open if you use the GUI interface to open a file.

But, if for some reason you have to open one in terminal (because of permissions), and nano is still too scary, sudo gedit file.txt will open the said file in gedit.

You will then have a GUI interface of a text editor with all the familiar buttons and menus. I won’t go into detail for these, as if you are struggling to use even gedit, then there is really little hope for you!

Ubuntu Editors


© 2012-2017