Unix: ne Editor

General Introduction

The ne editor (short for “nice editor”) is a full-screen editor available for Unix systems. It was developed by Sebastiano Vigna of the University of Milan, Italy, to provide a friendly alternative to vi , another well-known Unix editor. Thus, ne was designed to be both user friendly and powerful. It provides the user with a choice of working interfaces so that you have the option of issuing commands through control and function keys, at the command line, or by using menus.

Command Notations Used in this Handout

Because ne’s menu is fairly straightforward and easy to use, instruction in this handout will focus on how to carry out various commands using either control and function keys or command line abbreviations. Control keys will be denoted by a caret [^] followed by a another character. For example, ^x indicates that the <Ctrl> key should be held down while you hit the x key. Function keys are denoted by f n where n is the number of the function key. Command line abbreviations used in the body of this handout will be shown as : X. These notations mean that you need to activate the command line (see the section on Using the Command and Input Line) and then type in the character(s) indicated (such as X ).

Starting ne

To start ne, at the Unix prompt type ne , optionally followed by the name of the file you wish to edit. If you are creating a new file, use the name you wish to give to the new file. Note that when opening a new file in this manner you will get a message saying “Can’t open file. Check existence and permissions”. Don’t worry, that’s just ne’s way of saying the file doesn’t already exist. As soon as you start typing, this message will disappear and the name that you have given the file will appear on the status bar at the bottom of the screen.

% ne filename

Then press < Return> . You will see a screen similar to the one below:

I'm a wandering rhino,as  lonely  as  can  beyou  should  never  see  a  rhinoas  lonely  as  is  me.L:    1  C:    1  ai---fpvu-t----  49  song

The last line of the screen is the status bar. It provides the user with information about the current cursor position (L: stands for the current line number, C: for the current column number) and the name of the document in which you are working.

Common Status Bar Flags

You might also note that some other letters/flags (such as i, p, v, u, t) provide you with information about the current system preferences. The characters denoted in the status bar, known in ne as flags, can provide you with valuable information about features which are currently in use. Here is a list of the flags you will encounter most frequently. Most of these flags are discussed later in this document. (The Flags command will show you a complete list of flags and the commands associated with each.)

i insert flag is on a autoindent is on
b backsearch is on w wordwrap is on
f free form flag is on u undo flag is on
M you are marking a block V you are marking a vertical block
R you are recording a macro r read only flag is on

The Three Faces of ne

We’ve already mentioned that you may issue commands in ne from a command line, by using control and function keys, or by using a menu. Pages 7-10 of this document provide a compilation of ne commands and the way they might be executed using any one of these methods. Now we’ll take a look at how you might use each of these interfaces. Note that ne’s commands and command abbreviations are not case sensitive. You may use upper or lower case for any ne commands.

Using the Menu

One of the nicest aspects of ne, especially for new users, is that the most often used commands are available to you through a menu. (Menus are not available in most other Unix editors.) The menu will not appear when you first start ne, but you may activate it at any time by hitting the <Esc> key or the < f1 > key. The menu should appear as follows:


You navigate through ne’s menus with your cursor (a.k.a “arrow”) keys. Use the left and right arrow keys to select a menu, and the up and down arrow keys to select an option available under that menu. Once you’ve selected the menu item you wish to use, hitting the <Return> key will activate that option. Another shortcut for moving about in the menu is to use the alphabetic keys that correspond to the first letter of the menu item you wish to use. Uppercase letters are used to move along the Main Menu (i.e., F for File, D for Document, E for Edit, etc.). Lowercase letters will move you to options in the submenus. For example, if you are currently displaying the File menu options, typing s will move you to File/Save , while q would move you to File/Quit . Capital S , on the other hand would move you from the File menu to the Search menu. If there is more than one menu option with the same first letter, hitting the letter again will move to the next item in the sequence. To get rid of menus, simply hit the <Esc> key (or < f1 > key) again.

Shortcut Keys

You might notice as you move around the menu that some menu options have additional characters displayed to the right of that option. These characters show you how to invoke the same commands directly from the keyboard. The shortcuts identified with alphabetic characters usually begin with the ^ character, which indicates that you use the < Ctrl> key in combination with the alphabetic key. Be aware, however, that the operation of function keys is not consistent across communications packages. In Telnet or LAN, for example, some function keys may not work properly.

Using the Command and the Input Line

Another method for issuing a command is to execute it from the command line . In fact, most of ne’s obscure or infrequently used commands are not in its menus, nor are they available through keyboard shortcuts, so knowing how to get to the command line is important. You can get to the command line either by going to the menu and selecting Exec from the Extras menu, or by using the keyboard shortcut ^k (holding the < Ctrl> key down while pressing the k key). When you activate the command line, the status bar will temporarily disappear and you will see the following prompt:

Command:

At the command prompt you may type in the command you wish to execute, either by typing in the full name of the command or its command abbreviation. For example, if you wished to move your cursor to the end of the current file, you could activate the command line (with ^k ) and enter MoveEOF (which is the full name of that command) or you could use that command’s abbreviation, EOF . Remember, when you issue commands in ne, case does not matter, so moveeof and eof work equally well.

For some commands you issue, ne may need additional information to be able to carry out the command effectively. For example, if you wished to search for a string of text, you might issue the Find command (either from the menu, ^f , or from the command line), at which point ne would activate the input line for you to type in the string of text you wish to find. As with the command line, the input line temporarily replaces the status bar and will provide a prompt to solicit the information needed. The Find command, for example, would elicit the following prompt at the input line:

Find:    _

You could then type in the string you wish to search for. You will find in using the command and the input lines that you can shorten the process by issuing the command and including the necessary argument on the command line at the same time. For example, if you were to type at the command line find xxx (where xxx is the search string), you bypass the input line and the command is executed immediately. Note that in this document, commands that are entered on the command line are given in the form : command . You will not type the colon, which simply indicates that you should activate the command line by entering ^k .

Your previous commands and responses to the input line are available to you. When you activate the command line or are prompted for line input , your can access your previous commands or inputs by using the up and down arrow keys. You can also edit your command and input lines before entering them. If you change your mind, the < Esc > or < f1 > keys will abort the operation.

Getting Help

If at any point you need more information about various commands in ne, you may access Help in any of the following ways:

Activate the menu by hitting the <Esc> key, then select Help from the Extras menu.

Press < f10 > to activate the help screens.

Press ^k to activate the command line and then enter h (or help ) there.

When Help is activated, you may use direction keys to move among the various help options or, by pressing the first character of the command you wish to get help on, you can move quickly through the command list selecting commands that begin with that character. Pressing <Esc> or < f1 > will take you out of Help and return you to your ne session.

Entering Text

Unless you specify otherwise, ne works in an insert mode. Thus, wherever your cursor is located in a document, when you start typing, anything you type will be entered into the file. Try typing a few short lines and hit <Return> at the end of each of line. Unlike a word processor, ne does not use automatically wrap paragraphs (unless you use the WordWrap command; refer to the section on customizing ne for more information). Correct your mistakes with the < Backspace> or <Delete> keys. (Their exact operation may vary across different terminal emulations and communications programs you may be using. If the <Backspace> key doesn’t work properly on your system, try using the ^h key combination to delete characters to the left of the cursor.)

Cursor Navigation

It is very easy to move around in a file by using the arrow keys, but there are several other ways to move around in a document. Many of these are found in the menu under Navigation along with their keyboard shortcuts. All of them correspond to commands you can issue from the command line as well. For normal, everyday use the following keyboard shortcuts are probably the quickest way to move around.

^n moves the cursor to the next screen
^p moves the cursor to the previous screen
f8 moves the cursor to the next word
f7 moves the cursor to the previous word
^a moves to the beginning of a line
^e moves to the end of a line
^j prompts you for the number of a specific line you wish to jump to
:sof moves you to the beginning of the document (enter from command line)
:eof moves you to the end of the document (enter from command line)

For a listing of other navigational commands, refer to the Compendium of ne Commands at the end of this handout.

Basic Editing

Marking Blocks

Crucial to many of the editing activities in ne is understanding how to select or mark blocks of text prior to carrying out various editing actions. In particular, copying and cutting will require that you mark text to be cut or copied prior to executing the command. To mark a block of text, first position your cursor on the first character of the block, then type ^b. This will turn on the marker — look at the status bar and you should see that the M flag is on, which indicates marking is activated. Then move the cursor to the end of the text you are marking. By positioning your cursor in this manner, you have indicated the end of the block. Now you may proceed with executing your command of choice, whether it be cutting, copying, or deleting.

Of interest to folks who work with columnar text is that ne also provides the ability to mark vertical blocks. To do this, place your cursor at the upper left corner of the rectangle of text you wish to select, and type ^@ (or :mv). The vertical mark flag (V) should appear in the status bar. Now move just to the right of the character at the lower right corner of your desired selection. Then carry out your copy, cut, or deletion of text. See the section on Pasting Text for information on pasting vertical blocks.

Deleting/Cutting Characters, Lines and Blocks of Text

To delete a character, first place your cursor on that character. Then, you may use any of the following commands:

:del deletes the character under the cursor. (Your < Delete > key may work too, depending on your terminal emulator)
^h deletes the character to the left of your cursor
^y deletes the current line
^u undeletes the line that was deleted with the above command (only undoes last line deleted)
:de deletes from the current character to the end of the line

To delete multiple characters, words, multiple lines, multiple paragraphs or other blocks of text, you will first need to mark the block as described above and then you may select one of the following:

^x cuts the block of text and stores it in a clip (buffer)
:e erases the block of text; does not store in a clip

Copying Text

If you wish to make a duplicate copy of existing text, you should use the copy command. First, mark the block of text you wish to copy and then use the ^c shortcut combination to execute the Copy command. Once the desired text is copied to the current clip, position the cursor at the place you wish to insert the text and then use the Paste command described below to insert the contents of the clip.

Pasting Text

Often, when you cut or copy text, you may wish to reinsert it in another location within the document. In ne, Paste will allow you to insert the last portion of text on which you used the Cut or Copy command. (This does not apply to text removed with the Erase or DeleteLine commands. Unlike Cut and Copy , Erase and DeleteLine do not save text to a clip.) To Paste text, place the cursor where you wish the text to appear. Then use ^v (or :p ) to reinsert the text. If you wish to paste the contents of the current clip as a rectangle rather than as lines (see MarkVertical ), place your cursor where the text is to be inserted and then type ^w (or :pv , short for PasteVert ).

Undoing/Redoing

Be sure to remember this command; you can use it to undo your mistakes. Or, if need be, you can redo your actions. To undo, use f5 or :u . To redo, use f6 or :re . You can Undo an unlimited number of changes. You can Redo them as well as long as you haven’t made any more changes since you undid them.

File and Document Commands

One of ne’s real strengths is the ease with which it allows you to work with multiple files. This section provides some of the basic commands to Quit , Save , Open and move between documents ( NextDoc and PrevDoc ). See the Compendium of ne Commands for a more in-depth list.

Quitting and/or Saving a File

There are several ways you might choose to either quit or save a file.

^s to Save your file but not Quit ne (this is good to do periodically in case of machine crash!).
^q to Close the current file (and Quit ne if this is the only file in use); prompts to see if you wish to save changes; if multiple files are open, ne remains active.
:q closes all files; prompts to see if you wish to save changes, then quits ne.

“Emergency” Saves

As will happen, especially when you are working on an important document, system crashes or other events may cause your file editing to be rudely interrupted. When this occurs, all may not be lost. ne will attempt to save your file for you. If a document already has a name, ne will create a document of the same name prefixed with the # sign, . If you have not yet named the file, ne will give the file a name with unique hexadecimal numbers. Once you get back up and going, look for these files and use them to recover what would have been lost work.

Opening Documents

Once you are in ne, you can open files by applying one of the following commands:

^o opens a file into the current window; will ask you to specify filename at input line; will prompt you indicating that it will close any document previously in the window. (See Open .)
:on opens specified file into a new window. (See OpenNew ).
:n opens a new, blank window to allow creation of a new file. (See New .)

Moving Between Documents

It’s easy to move between document windows with the following commands:

:nd moves you to the next document. (See NextDoc .)
:pd moves you to the previous document. (See PrevDoc .)
:sd allows you to select from a list of currently open documents to move to. (See SelectDoc .)

Find and Replace

Find and Replace commands can be very helpful in assisting you either to move to specific portions of your document or to modify a string of text quickly and easily. The Find command is easy to use. One way to execute this command is to use the ^f keyboard shortcut and then get to the input line where you can type in the string of text you are seeking. (Using the command method, you could type f string where string is the text you wish to find.) The Replace command will look for the last string indicated by the Find command. This means that you will usually need to start the process by activating Find and then use Replace . In general, you might use the following steps:

If you wish to search through the entire document, activate the command line and type sof (start of file). Otherwise your search will start at the current cursor position. Unless you specify otherwise with the SearchBack command, searches will occur in a forward direction.

^f and then when prompted enter the string of text you wish to find; hit <Return> .

^r and type in the text you wish to replace the old string with; hit <Return> .

ne will move you to the first incidence of that string it can locate. You will then be presented with the following choices: (Yes/No/Last/All/Quit/Backward) . Type in the first character of the desired action.

Choosing Yes replaces the string ne has found with the new string you have indicated. Then ne will continue the search for the next incidence of the string. Choosing No will cause ne to skip that occurrence and go on to search for the next. Last allows you to change the current string and stop the search. All replaces all occurrences of the string found, and Backward allows you to search in a backward direction.

Customizing ne

There are several options you can set from within ne that can affect how you use this editor. For example, you can set a mode RightMargin , turn on WordWrap , turn on AutoIndent , turn Insert mode off to overtype, etc.. You can make all these changes either from the menu (select Preferences ) or by issuing commands from the command line. Refer to the Compendium of ne Commands for further information on these preferences. You may wish to apply several preference changes to the majority of your files. If this is the case, you may choose to save these as your default preferences ( :sdp ). When you do this, ne will create a file named .default#ap in a directory named .ne in which to store your preference settings. Your preferences will then be loaded anytime ne is activated.

Compendium of ne Commands

The table below provides a fairly comprehensive listing of ne commands. The following describes how to use the table:

Command gives the command’s full and proper name. These command names can be used at the command/input line, or you may use command line shortcuts as indicated in the third column.

Explanation of Command gives brief description of action which will be executed by the command.

Command Line Abr gives abbreviation for command which can be input at the command line. In instances where string is included with a command, type in the argument. [n] indicates that you can type in the number of times, characters, etc. that a command can take action upon. Command features which can toggle on and off will show the notation [0/1]. The command used by itself will simply toggle the feature on or off. Command 0 turns off the feature and Command 1 turns on the feature.

Shortcut Key(s) gives a shortcut key combination if there is one for the given command. Note that to use shortcut keys tied to alphabetic keys (a-z), you must hold down the <Ctrl> key (indicated by the ^ symbol in this table) in combination with the alphabetic keyboard shortcut.

Menu Location indicates location of command on the ne menu. For example, File/Save would indicate that you should select File from the main menu and then select Save .

Command Explanation of Command Command Line Abr Shortcut Key(s) Menu Location
Support Commands
Help provides help on the command specified H f10 Extras/Help…
Exec places you on the command/input line and asks for a command to execute EX ^K Extras/Exec…
Flags explains all the flags in the status bar and their associated commands FLAG
File Commands
Quit closes files, prompts for confirmation, & exits ne Q File/Quit Now
Exit saves files & exits ne X File/Exit (Save)
Save saves current file using default name S ^S File/Save
SaveAs save current document to newly specified path/name SA File/Save As…
CloseDoc closes current file; if it’s the only file also exits ne CD ^Q Documents/Close
Clear clears contents of current document & its buffers CL Documents/Clear
NewDoc creates a new, empty, unnamed document N Documents/New
Open loads specified file into the current document window O ^O File/Open…
OpenNew same as open but loads the specified file into a new document window ON File/Open New…
NextDoc next doc in document list becomes the current document ND f2 Documents/Next
PrevDoc previous doc in document list becomes the current document PD f3 Documents/Prev
SelectDoc opens a list of currently loaded documents; select one to load as the current document SD f4 Documents/Select
Command Explanation of Command Command Line Abv Shortcut Key(s) Menu Location
Navigation Commands
PageUp moves cursor to next screen PUP [n] ^N Navigaton/Page Up
PageDown moves cursor to previous screen PDN [n] ^P Navigation/Page Down
MoveEOF moves cursor to end of the file EOF Navigation/Top/Bottom
MoveSOF moves cursor to beginning of the file SOF Navigation/Top/Bottom
MoveEOL moves cursor to end of line EOL ^E Navigation/End of Line
MoveSOL moves cursor to beginning of line SOL ^A Navigation/Beg of Line
NextWord moves cursor to next word NW [n] f8 Navigation/Next Word
PrevWord moves cursor to previous word PW [n] f7 Navigation/Prev Word
GotoLine moves cursor to specified line GL [n] ^J Search/Goto Line…
GotoColumn moves cursor to specified column GC [n] Search/Goto Col…
GotoMark moves cursor to current mark if there is one GM Search/Goto Mark
LineUp moves cursor up 1 line n times LU [n] Navigation/Line Up
LineDown moves cursor down 1 line n times LD [n] Navigation/Line Down
MoveLeft moves cursor left 1 character n times ML [n] Navigation/Move Left
MoveRight moves cursor right 1 character n times MR [n] Navigation/Move Right
SetBookmark allows you to set up to 10 bookmarks per document (0-9) for ease of moving to specified areas in a document SBM [n]
GotoBookmark moves cursor to specified bookmark GBM [n]
Editing Commands
Mark sets mark at current cursor position; selects text between mark and position to which cursor is moved M ^B Edit/Mark Block
MarkVert same as above, but allows vertical/rectangular selection MV ^@ Edit/Mark Vert
Copy copies selection indicated by marked block into the clip C [n] ^C Edit/Copy
Cut copies selection indicated by marked block into clip and deletes from current position CU [n] ^X Edit/Cut
Paste pastes contents from specified clip (default from current clip) to current location P [n] ^V Edit/Paste
Erase same as cut except block of text deleted is not copied into the clip E Edit/Erase
Undo undoes the last n actions (default if not specified is last action) U [n] f5 Extras/Undo
Redo redoes the last n actions (default if not specified is last action) RE [n] f6 Extras/Redo
DeleteLine deletes n lines from current cursor position DL [n] ^Y
UndelLine at current cursor position, inserts n times the last line deleted UL [n] ^U Extras/Undel Line
DeleteEOL deletes characters between current cursor position & end of line DE
Command Explanation of Command Command Line Abv Shortcut Key(s) Menu Location
DeleteChar deletes n characters from current cursor position (1 if not specified) DC [n]
Backspace deletes n characters to the right of cursor BS [n]
Insert toggle on & off; if on then text is inserted; if off then puts ne in overtype mode I Prefs/Insert/Over
Formatting Commands
Center centers n lines from current cursor position CE [n] Extras/Center
ToUpper changes case from lower to upper TU [n] Extras/ToUpper
ToLower changes case from upper to lower TL [n] Extras/ToLower
Capitalize changes first letter to upper and all other letters in a word to lower CA Extras/Capitalize
Paragraph reformats paragraphs PA [n] Extras/Paragraph
RightMargin sets the right margin for specified n RM [n] Prefs/Right Margin…
WordWrap toggle to turn wordwrap on/off; if on break lines of text longer than right margin WW [0/1] Prefs/WordWrap
AutoIndent toggle to turn autoindent on/off; if on, will indent new line to replicate previous line’s spacing AI [0/1] Prefs/AutoIndent
TabSize determines number of spaces in tabs TS [n] Prefs/Tab Size…
Search/ReplaceCommands
Find searches for a specified pattern and places cursor on first occurrence of the pattern F [string] ^F Search/Find…
FindRegExp sames as above except searches for extended regular expression FX [string] ^_ Search/Find RegExp…
Replace goes to the first occurrence of the most recent find string and gives interactive replacement options R [string] ^R Search/Replace
ReplaceOnce same as above with no interaction; replaces first occurrence with specified replacement string R1 [string] Search/Replace Once…
ReplaceAll replaces all occurrences of last search string with specified replacement string RA [string] Search/Replace All
RepeatLast repeats the last find or replace operation RL [times] ^G Search/Repeat Last
MatchBracket moves cursor to the bracket associated with bracket cursor is currently on. If cursor is not on a bracket or no matching bracket is found, error message is given. MB ^] Search/Match Bracket
SearchBack toggle on & off; when on searches backwards SB [0/1]
CaseSearch toggle on & off; when on distinguishes between upper/lower case. Default is off. CS [0/1]
Macro Commands
Record toggle on & off; when on (true) starts recording macro Rec [0/1] ^T Macros/Start/Stop Rec
Play plays current macro n times (once if n is not specified) PL

PL [n]

f9 Macros/Play Once

Macros/Play Many…

Command Explanation of Command Command Line Abv Shortcut Key(s) Menu Location
OpenMacro opens specified file as macro OM [filename] Macros/Open Macro…
Macro executes specified file as macro MA [filename] Macros/Play Macro
SaveMacro saves current macro to specified name SM [filename] Macros/Save Macro
Preference Commands
Insert toggle on & off; if on then text you type is inserted; if off then puts ne in overtype mode I Prefs/Insert/Over
FastGUI toggle on & off; when on displays faster (status bar & menu bars have less highlighting) FG [0/1] Prefs/Fast GUI
FreeForm toggle on & off; when on can move cursor anywhere on screen even where no text is present FF [0/1] Prefs/FreeForm
StatusBar toggle on & off; when on status bar is displayed. ST [0/1] Prefs/Status Bar
PreserveCR toggles whether to treat carriage returns as regular characters or new lines when loading a file PCR Prefs/PreserveCR
ReadOnly toggle on & off; when on (true) cannot edit current document RO [0/1]
LoadPrefs loads specified preference file and uses it in current session LP [filename] Prefs/Load Prefs
SavePrefs saves current preferences to specified file for later use SP [filename] Prefs/Save Prefs
LoadAutoPrefs loads prefs file from home directory .ne file relative to current file LAP Prefs/Load Auto Prefs
SaveAutoPrefs saves current prefs to file in home directory .ne file relative to current document name SAP Prefs/Save Auto Prefs
SaveDefPrefs saves current preferences to home directory .ne/.default#ap file; this file will be loaded by ne at startup SDP Prefs/Save Def Prefs