Text Editors

Rob

Administrator
Staff member
Credits
46
If I were to choose one of the main reason why people use PCs, I would definitely say for writing. With a computer and a word processing program, cross outs, white out and crumpled up paper has disappeared forever. Linux is just as well suited for word processing as any other operating system. There are several excellent word processing programs for Linux like AbiWord, KWord, part of the KOffice suite and the OpenOffice.org suite's word processor. We'll talk about these kinds of programs in a later lesson. First, we should talk about the terminal mode text editors that are available for Linux.

Why use a text editor?

A text editor is just like a word processor without a lot of features. All operating systems come with a basic text editor. Linux comes with several. The main use of a text editor is for writing something in plain text with no formatting so that another program can read it. Based on the information it gets from that file, the program will run one way or another.

The text editor "vi"
The most popular text editor for Linux is called 'vi'. This is a program that comes from UNIX. There is a more recent version called 'vim' which means 'vi improved'. The problem with 'vi' or 'vim' is that a lot of people don't like it. You have to remember a lot of key combinations to do stuff that other text editors will do for you more easily.

We should go through some basic 'vi' commands, because I have found that 'vi' is good if I want to get into a text file quickly and change something or I want to write a short note to myself. I generally do not use "vi" for anything that requires more than about 30 seconds of work, but there are people who swear by 'vi' and do all kinds of things with it like designing entire websites.

Working with 'vi'

Let's make a text file. Type:

Code:
vi try_vi
You'll see a line of tildes down the left side and the name 'tryvi' at the bottom and [new file].

To write something, you have to press ESC and the 'i' key (i for insert). Even if you don't press 'ESC-i' it usually gets the idea that you want to type something and lets you do it after a few keystrokes. You should get used to the 'ESC-i' keys so you don't end up writing 'ar John' instead of 'Dear John'.

Press ESC + 'i' then type: hello vi

If you wrote jello vi or jello bi or something I don't want to know about, you can always erase your mistakes with the backspace key.

To save this file, you would press ESC then the colon key ':' then 'w' (write)

To save the file and quit vi, you would press ESC, ESC the colon key ':' then wq (write, quit)

To quit without saving, press ESC, ':' then 'q'. Vi may protest if you've written something and you don't want to save it. If you press ESC ':' 'q!' with an exclamation point, vi will accept it and not save your changes.

That's vi in a nutshell, or more like a sesame seed. There are a lot of commands in vi - and you may explore those on your own at a later date, on your own terms and in the privacy of your own home.

Using 'joe'

'joe'- sounds like a comic strip. Actually, they are two other text editors that I like and I think are a little easier to manage. They're like 'vi' in that you use them to create and edit non-formatted text, but they're a little more user-friendly. Using 'joe' 'joe' was created by Joseph Allen, so that's why it's called Joe. I suppose if his name had been Hrothgar Allen, it would have been called 'hroth'.

To use 'joe', you could type:
Code:
joe try_joe
You won't see the tildes like vi. It looks a little friendlier. The majority of joe's commands are based on the CTRL-K keys and a third key. The most important of these is CTRL-K-H which gets you 'help'. Help shows you the key combinations to use with 'joe'.

The most important thing about 'joe' is the logical concept that you can just start writing if you want. Try writing anything you want.

To save it, press CTRL-K-D. To save and quit, CTRL-K-X.

To quit without saving, CTRL-C, (without the K).

If you want to see the other features of 'joe', press CTRL-K-H, as I mentioned before.

My favorite little added feature of 'joe' is that if you edit a file again, it will save the previous file with a tilde on the end, like 'tryjoe~' That little tilde file has saved my life a couple of times. (well, maybe not my life) But it has saved me a lot of work. I've made some changes to a file and then found out that wasn't a good idea. I could always fall back on the tilde file, which is a copy of your previous edit.

'joe' is a very good option for writing those short text files that you'll need.

Using 'pico'

'pico' is another friendly text editor. If you type:

Code:
pico try_pico
You'll see the commands you need in 'pico' specified at the bottom. You can just start writing anything you want.

To save the file, press CTRL-o. To save and quit or to just quit, press CTRL-x

Pico will always ask you if you want to do what you're doing. That's good. Questions like that will keep you from sending a file into non-existence without wanting to. All the other commands you'll need are at the bottom of the page.

Well, this is our little overview of the main text editors available for Linux. In our next lesson, we're going to need to use one in order to make our work in Linux a little bit safer and easier.
 


wizardfromoz

Super Moderator
Staff member
Gold Supporter
Credits
2,015
Nice article Rob, I like Joe, that one is new to me.

I only happened to wander in when @AlienGod input above and bumped it, but while I am here, I hope I may bring The Viewers an update.

pico is from the nonfree email client pine, and is now basically deprecated in favour of nano, which is licensed under the GPL (GNU Public Licence).

In many Distros, if you type and enter

Code:
pico
... you will be redirected in to nano, which shares many of the same features.

If you wish to learn more about nano, https://www.nano-editor.org/dist/v2.2/nano.html explains a lot, and also features pico compatibility.

Cheers all

Wizard
 

NightsLast

New Member
Credits
0
Nice article Rob, I like Joe, that one is new to me.

I only happened to wander in when @AlienGod input above and bumped it, but while I am here, I hope I may bring The Viewers an update.

pico is from the nonfree email client pine, and is now basically deprecated in favour of nano, which is licensed under the GPL (GNU Public Licence).

In many Distros, if you type and enter

Code:
pico
... you will be redirected in to nano, which shares many of the same features.

If you wish to learn more about nano, https://www.nano-editor.org/dist/v2.2/nano.html explains a lot, and also features pico compatibility.

Cheers all

Wizard
I've used pico ever since RH4.2 and I never realized it was switched to nano until reading this.. I do miss pine... I use to have a lot of fun messing with people with pine... making them think I sent them an email from their email account... I miss those days heh
 

wizardfromoz

Super Moderator
Staff member
Gold Supporter
Credits
2,015
G'day Peer :)

Keep in mind that Rob's article was written 5 and a half years ago.

Nano was not around then. Nano is basically an improved or modified version of Pico.

When a package or command is made obsolete or redundant, we call it "deprecated", so Pico was deprecated in favour of Nano.

In the same way, yaourt, which you used to install your Timeshift on Arch, is being deprecated in favour of

yay - Yet Another Yaourt

Hope this helps

Wizard

BTW that codeLobster looks interesting, @clod - welcome to linux.org and thanks for sharing :D
 
  • Like
Reactions: Rob

Trenix25

Member
Credits
387
I need some help. I can't get vi to work right. My delete key moves the cursor back one column, but it doesn't delete the character. I went into /usr/share/terminfo/l/ and linked (-sf ) linux to linux-vt. At least now stty provides more information. I turned on compatible, I think that's what it's called, in the system wide config file. Insert mode doesn't want to kick in. It switches back to command mode when I use my arrow keys. It makes working on text files really frustrating. I have used vi (elvis) for years to type in LPC code for endless hours. I hope I don't have to abandon vi and learn how ro use a different editor. I need to have it say what mode it's in at the bottom of the screen, along with the current cursor position.
 

sp331yi

Active Member
Credits
2,328
Everyone has their favorite. Mine is one of the oldest -- Midnight Commander AKA mc --

much easier than vi - recommended!
 

JasKinasis

Well-Known Member
Credits
866
Everyone has their favorite. Mine is one of the oldest -- Midnight Commander AKA mc --

much easier than vi - recommended!
Midnight Commander is a file manager for the terminal, not a text editor.

Midnight commander uses your system’s default terminal text editor to edit files. So if your systems default editor is vi, it will use vi. If it’s emacs it will use emacs.

I think most distros are configured to use nano as the default editor nowadays, so I’m guessing you’re probably using nano in mc.

Personally, I prefer vi/vim in the terminal and on the desktop, purely because it has better ergonomics than other editors.
I have arthritis in my wrists and hands, I find that the keybinds in emacs and nano (and most other graphical editors) hurt my hands.
And being a professional programmer, I use the keyboard a lot. So vi/vim saves me a lot of literal pain.

A number of editors feature plugins, or extensions that provide vi-like keybinds, but their implementations are often incomplete, so I still end up performing keyboard gymnastics to perform certain tasks.

For example- Emacs is a great editor, I really like it. It has some amazing and very useful extensions. But it’s default keybinds are literally painful.

There are things like evil mode and spacemacs, to provide vi like keybinds for emacs, but again, it’s only a partial implementation. I still have to rely on painful gymnastics for certain tasks.
So for that reason alone, I’ve stuck with vi/vim.

And vi does have an undeserved reputation for being difficult to learn. It’s certainly not for everybody, but I wouldn’t say it’s difficult.
It uses a completely different paradigm/workflow to most other editors, but once you have learnt the basics (using vimtutor) and got used to switching between edit mode and command mode- it’s an extremely powerful and efficient way to edit text. Especially if you can touch-type, because your hands rarely need to move from the home row. So if you have any problems with your hands, I’d definitely recommend giving vi/vim a go!

Most people will be ok with nano, but if you have more complex editing needs - then definitely try vi/vim or emacs!
 

sp331yi

Active Member
Credits
2,328
vi is like reverse-polish hp calc was, in the day! Learned it once and quickly forgot it.

Why the emacs vs vi contoversy in the first place?
Geany and leafpad -- are they txt editors, or what? but I prefer mc to edit config files, sources.list and the like.
Thanks for the clarification. Like I've said, I'm just a mechanic at heart!
 


Members online


Latest posts

Top