LINUX CLASSES - TEXT EDITORS

Can Pico Slow the Rotation of the Earth?

The Pico Editor

Pico, short for Pine Composer, started life as the built-in editor for the Pine email program. Lots of people use Pico as a text editor because they also use the friendly Pine program for email. The Pico text editor doesn't have a lot of fancy features, but it's a welcome alternative to the vi or Emacs editors because learning it is quick and easy. Cursor movement and text entry are straightforward, and--best of all--you don't have to learn any arcane commands: all commands are listed in a handy menu at the bottom of the screen.

To start Pico, enter a command like this:

pico bulb.joke

In response, you should see the file bulb.joke displayed on your screen in Pico, ready for editing, as shown here:

UW PICO(tm) 4.3 File: bulb.joke



Q: How many surrealists does it take to screw in a light bulb?

A: Two--one to hold the giraffe, and the other to fill the

bathtub with brightly colored machine tools.







[ Read 3 lines ]

^G Help ^O WriteOut ^R Read File ^Y Prev Pg ^K Cut Text   ^C Cur Pos
^X Exit ^J Justify  ^W Where is  ^V Next Pg ^U UnCut Text ^T To Spell

Getting around in Pico

Before we explore Pico commands, here's a summary of how to navigate your way around a file in Pico.

Positioning the Cursor

Move cursor one space right (also ctrl-N).
Move cursor one space left (also ctrl-P).
Move cursor up one line (also ctrl-F).
Move cursor down one line (also ctrl-B).
del Delete character at cursor (also ctrl-D).
ctrl-Y Move backward one screen (maybe F7).
ctrl-V Move forward one screen (also F8).
ctrl-A Move cursor to beginning of line.
ctrl-E Move cursor to end of line.


With the exception of the ctrl-Y (page down) command, text entry and cursor handling are identical to that of the Emacs editor, so we won't cover that again here.

The Pico Menu

When you start Pico you'll see this menu of commands:

^G Help ^O WriteOut ^R Read File ^Y Prev Pg ^K Cut Text ^C Cur Pos

^X Exit ^J Justify ^W Where is ^V Next Pg ^U UnCut Text ^T To Spell

Here's a list of what they mean. Note that the circumflex (^) stands for ctrl.

Pico Commands

ctrl-G Display help screens.
ctrl-O Write file to disk.
ctrl-R Read another file.
ctrl-K Cut line or marked text.
ctrl-C Display cursor position.
ctrl-X Exit from Pico.
ctrl-J Reflow the paragraph.
ctrl-W Search for text.
ctrl-U Paste (uncut) text.
ctrl-T Run spelling checker.

Trying Out Some Pico Commands

Now let's try out some Pico commands.

Saving and Exiting

Saving your file is easy with Pico--just press ctrl-O to write your file to disk and remain in the editor, or press ctrl-X and respond y to the Save Modified Buffer? prompt to save and exit.

If you want to exit from Pico without saving your file, press ctrl-X and respond n to the Save Modified Buffer? prompt.

Inserting Another File

To insert another file into the one you're currently editing, position the cursor where you want to insert the file, press ctrl-R, and enter the name of the file you wish to insert at the prompt that appears on your screen:

Insert file from home directory: ______________
^G Get Help ^T To Files
^C Cancel

If you can't remember the name of the file to insert, press ctrl-T to display a list of all your files. If you ultimately decide not to insert it, press ctrl-C to cancel.

Cutting and Pasting with Pico

If all you want to do is cut and paste a line of text, you can use ctrl-K to delete the current line and ctrl-U to paste it somewhere else. Pico also lets you cut and paste blocks of text. Put your cursor on the word light on the first line of the bulb.joke file and press ctrl-^ ( the circumflex is the shifted 6 key).

Nothing happens right away, but as you move the cursor, it highlights a block of text. Move the cursor to the end of the word giraffe on the next line--your file should look like this:

UW PICO(tm) 4.3 File: bulb.joke



Q: How many surrealists does it take to screw in a light bulb?

A: Two--one to hold the giraffe, and the other to fill the

bathtub with brightly colored machine tools.

Once you've marked a block of text, ctrl-K acts a bit differently from before. Instead of deleting the entire line where the cursor is located, it deletes the highlighted block. You can then use ctrl-U to paste the deleted block elsewhere.

Tip: You don't have to paste the deleted text right away, or ever. ctrl-K can be used simply as a handy way of deleting unwanted text. (Deleted text goes to an invisible clipboard, and it disappears once you delete more text.)

Pico Bells and Whistles

Pico has a few nifty features you might not expect to find in a simple text editor. For example, ctrl-J will justify the sentences in the current paragraph. Type a bunch of short sentences on separate lines and try it. If you don't like the results, ctrl-U will undo the operation.

Pico also has a built-in spelling checker you can call up with ctrl-T from within a file. If Pico doesn't find any dubious words in the current document, nothing much happens except that the message "Done checking spelling" appears at the bottom of the screen.

And if you'd like to know exactly where you are within a file (on which line and at which character), or if you'd like a quick character or line count, press ctrl-C and look in the message area at the bottom of the screen for something like this:

line 2 of 4 (50%), character 65 of 173 (37%)

Parting Words about Pico

Pico is my personal favorite in text editors because it's easy to use and starts quickly. Pico is under constant development at the University of Washington. For more information, you can visit the Pine Information Center on the Web at http://www.washington.edu/pine. You can even download the latest version of Pico for Linux there.

Previous Lesson: The Emacs Editor
Next Lesson: Slicing & Dicing

[ RETURN TO INDEX ]


   

Comments - most recent first
(Please feel free to answer questions posted by others!)

Isabelle     (05 Oct 2012, 20:00)
Hello! How do you copy and paste in PICO?
yohannis betela     (30 Mar 2012, 17:55)
please tell me the function of pico wave and un fortunatly it asks pass word i donot know it.
Matt Gilbert     (14 Feb 2012, 12:59)
There are a few questions here on how to copy and paste

In a linux CLI terminal, it can usually be done with the mouse actually. Left click and hold down while dragging and highlight the text you want to copy.

then move to, or switch to the terminal where you want to paste and right click, that's all there is to it.

You will need to have gpm (general purpose mouse) daemon / driver running.

see

man gpm
Matt Gilbert     (14 Feb 2012, 12:52)
Yes, PICO is worlds easier than vi or emacs, and should be fairly intuitive if you are migrating from a DOS world into UNIX, everything you need is really right there at the bottom of the screen.

Some distros may have NANO (nano) which is essentially the same but was developed after some copyright issues with PICO, iirc.

jstar remains my favorite linux text editor, it's actually part of joe (joes own editor) but jstar has keybindings similar to the venerable cp/m or DOS wordstar, with jstar, in the rare event you get lost, ctrl + j pops up a quick reference menu at the top.

I'd like to also mention two other linux command line text editors, that might seem friendlier to those migrating from the DOS or even Windoze world, and they are ne (nice editor) and diakonos. Both have menus across the top that can be brought up by hitting the ESC key and will have a familiar FILE EDIT HELP across the top with drop down menus. They are actually very nice editors, but I still prefer jstar, the author of this site is doing a great service by presenting vi, emacs, and pico / nano as they are historic editors from the nix world, and sooner or later, you WILL find yourself where the vi editor is your only option. This actually happened to me at a job where I was often called upon to help with a system in an unofficial capacity while they were waiting for the IT guy --- it was an asterisk system installed on a linux PBX system and all it had was vi and I nearly pulled my hair out trying to edit a simple text file - but I did get through it.
Charlotte aero     (06 Feb 2012, 21:05)
How do you make a new pico and never see it again i tryed on mochi but didnt get 5000 ag so can anyone tell me?
Neo     (18 Jan 2012, 19:08)
Hi Bob, can you show me where to install this and how to run it on windows OS? or have to install Linux based OS?
Niki     (12 Dec 2011, 19:51)
Hi Bob.
I'm tying to use pico in putty but it's not working.it seems the command is not found.why is this happening??
harry     (08 Aug 2011, 08:38)
In 'c' language how to cut and paste a para
Marcos Carlevaro     (12 Apr 2011, 20:28)
If you can't find pico in your Linux installation, try "nano".
vidit     (31 Mar 2011, 06:33)
here ctrl+k is used for cut and ctrl+u is used for paste.
Kevin     (30 Mar 2011, 20:38)
Chris: Depends on what program you use to access the command line & therefore pico with eg: if you are using PuTTY, simply copy the text you want to paste into the Windows clipboard then in PuTTY, right click to paste.
If you don't use PuTTY, check the documentation of whatever program you use instead for how to "paste".
Chris P. Bacon     (05 Nov 2010, 18:00)
Is there a way to paste into pico from another file like NotePad in Windows or something? I can copy from pico and paste to NotePad, but not visa versa. Thanks!
Kevin     (28 Apr 2010, 17:13)
Otto: Thanks for the reply.

I most definitely do not press the enter key at the end of editing the document. In fact, I ensure I cannot move to a new line by pressing the "down arrow". Once I confirm there isn't a new line, I directly exit the document (Control X) whilst saying "Yes" to saving it.

I am quite sure that Pico is inserting a new line because I don't get this happening when I View/Edit this document with Filezilla (FTP which allows you to download a file to a local system editor and upload it after editing). Since I don't always have access to the computer which has this but have access to my system via the web, it would be handy to be able to use Pico (or equivalent) without it inserting extra lines.

Any further thoughts? Thanks.
Otto     (28 Apr 2010, 14:27)
For Kevin:
I have never used Pico, but maybe, if it saves the last line without you pressing the Enter key, the blank line will go away? Maybe it's because of the carriage return.
Kevin     (15 Apr 2010, 01:31)
Hi Bob,

Thanks for the reply. When I pico <file>.txt and add a space at the first line then delete it, I get "1 <file>.txt" when I run wc -l <file>.txt

This was "0 <file>.txt" when I ran pico <file>.txt & exited without doing anything (ie: pico didn't ask to save any data).

Unfortunately pico seems to be insistent on tacking on an extra line (despite me trying to delete that line). Is there some configuration somewhere to stop this?

Cheers,
Kevin.
Bob Rankin     (13 Apr 2010, 08:06)
@Kevin, That line should disappear when you exit Pico. Verify with the "wc -l" command.
Cassandra L. Wanzer     (12 Apr 2010, 06:41)
Hi; Doctor Bob
I am a new student who needs to get up to speed.
I am so grateful for the free lessons.
Kevin     (07 Apr 2010, 21:43)
Thanks for the info!
Quick question: pico seems to insist on inserting a new blank line at the end of a file I edit. This causes problems with some code which is expecting a single line in this file - how to disable this behaviour?
(Yes, I did try to hitting the "delete" key when at that line but using the arrow keys show that that line still exists!)

I welcome your comments. However... I am puzzled by many people who say "Please send me the Linux tutorial." This website *is* your Linux Tutorial! Read everything here, learn all you can, ask questions if you like. But don't ask me to send what you already have. :-)

NO SPAM! If you post garbage, it will be deleted, and you will be banned.
*Name:
Email:
Notify me about new comments on this page
Hide my email
*Text:
 
 


Ask Bob Rankin - Free Tech Support


Copyright by - Privacy Policy
All rights reserved - Redistribution is allowed only with permission.

Popular Pages