Text Editors

Discussion in 'Beginner Tutorials' started by Rob, Jul 9, 2013.

  1. Rob

    Rob Administrator Staff Member

    Messages:
    573
    Likes Received:
    183
    Trophy Points:
    43
    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.
    Saptarshi Nag and DevynCJohnson like this.
  2. Primit1v3

    Primit1v3 Member

    Messages:
    37
    Likes Received:
    10
    Trophy Points:
    8
    Just tried to "sudo apt-get install pico" on Linux Mint 15 (Cinnamon) and it said package wasn't available but was mentioned by another app Nano...is Nano a rename and does it work the same as described here for Pico???
  3. alexaat

    alexaat New Member

    Messages:
    2
    Likes Received:
    3
    Trophy Points:
    3
    Nano is a text editor as well, designed to be replacement of Pico
    Arun BIsoyi and Primit1v3 like this.
  4. Virneto

    Virneto Member

    Messages:
    45
    Likes Received:
    21
    Trophy Points:
    8
    It is, and a good one. I like nano for its simplicity.
    But my favorite for web development is Gedit With all interesting pluggins, boy it Rocks!!
    Arun BIsoyi, Primit1v3 and Codypy1 like this.
  5. Primit1v3

    Primit1v3 Member

    Messages:
    37
    Likes Received:
    10
    Trophy Points:
    8
    I'm a big fan of Gedit and Geany. I see a lot about Nano and figure it's time to at least give it try but Gedit will probably stay my main editor.
    Jerry Stringer and Virneto like this.
  6. TheShellWave

    TheShellWave New Member

    Messages:
    2
    Likes Received:
    2
    Trophy Points:
    1
    I like vi since it is always there when I have to logon to a UNIX, Linux, or FreeBSD machines at my previous job. It is always there, even a freshly configured machine. Anyways, it's more of a personal preference.
    Rob likes this.
  7. flunwyc

    flunwyc Member

    Messages:
    99
    Likes Received:
    60
    Trophy Points:
    18
    Another nano user here...

    I used to use vi/vim years ago but got lazy at some point and now can only use vi as far as clumsily opening a file editing a line, writing the file and quitting...
  8. T Wolf

    T Wolf New Member

    Messages:
    2
    Likes Received:
    2
    Trophy Points:
    1
    Don't forget the way to keep it easy until you decide. Use the e3 editor which uses keybindinds for multiple apps but is small. From the developer:

    This makes it perfect for learning the basic vi, emacs, and pico keybindings even on a low resource system. Lets people end the old vi/emacs flame war for themselves, and although the power of emacs/vi are lost without the extensions, new users can learn the navigation and go from there.
  9. Videodrome

    Videodrome Active Member

    Messages:
    159
    Likes Received:
    63
    Trophy Points:
    28
    I usually use Nano, but I can fumble my way through Vi if I have to do a quick edit.
  10. Kovax

    Kovax Member

    Messages:
    34
    Likes Received:
    17
    Trophy Points:
    8
    I LOVE the vi editor... it took me some time to get comfortable with it but once I did I loved it!!!

    HJKL baby

    Kovax
  11. Saptarshi Nag

    Saptarshi Nag Member

    Messages:
    33
    Likes Received:
    21
    Trophy Points:
    8
    I think nano & pico are same but vi is the best one.
    To know more about vim,watch the linux foundation video of 'introduction to vim'
    DevynCJohnson likes this.

Share This Page