Getting Started
Basic Operation
Selecting Text
Finding and Replacing Text
Cut and Paste
Using the Mouse
Keyboard Shortcuts
Shifting and Filling
File Format
Features for Programming
Programming with NEdit
Tabs/Emulated Tabs
Auto/Smart Indent
Syntax Highlighting
Finding Declarations (ctags)
Regular Expressions
RegEx Basic Syntax
RegEx Escape Sequences
RegEx Parenthetical Constructs
RegEx Advanced Topics
RegEx Examples
Macro/Shell Extensions
Shell Commands and Filters
Learn/Replay
Macro Language
Macro Subroutines
Action Routines
Customizing
Customizing NEdit
Preferences
X Resources
Key Binding
Highlighting Patterns
Smart Indent Macros
NEdit Command Line
Client/Server Mode
Crash Recovery
Version
Distribution Policy
Mailing Lists
Problems/Defects
NEdit is a standard GUI (Graphical User Interface) style text editor for programs and plain-text files. Users of Macintosh and MS Windows based text editors should find NEdit a familiar and comfortable environment. NEdit provides all of the standard menu, dialog, editing, and mouse support, as well as all of the standard shortcuts to which the users of modern GUI based environments are accustomed. For users of older style Unix editors, welcome to the world of mouse-based editing!
Help sections of interest to new users are listed under the "Basic Operation" heading in the top-level Help menu:
Programmers should also read the introductory section under the "Features for Programming" section:
Programming with NEdit
If you get into trouble, the Undo command in the Edit menu can reverse any modifications that you make. NEdit does not change the file you are editing until you tell it to Save.
Editing an Existing File
To open an existing file, choose Open... from the file menu. Select the file that you want to open in the pop-up dialog that appears and click on OK. You may open any number of files at the same time. Each file will appear in its own editor window. Using Open... rather than re-typing the NEdit command and running additional copies of NEdit, will give you quick access to all of the files you have open via the Windows menu, and ensure that you don't accidentally open the same file twice. NEdit has no "main" window. It remains running as long as at least one editor window is open.
Creating a New File
If you already have an empty (Untitled) window displayed, just begin typing in the window. To create a new Untitled window, choose New from the File menu. To give the file a name and save its contents to the disk, choose Save or Save As... from the File menu.
Backup Files
NEdit maintains periodic backups of the file you are editing so that you can recover the file in the event of a problem such as a system crash, network failure, or X server crash. These files are saved under the name `~filename` (on Unix) or `_filename` (on VMS), where filename is the name of the file you were editing. If an NEdit process is killed, some of these backup files may remain in your directory. (To remove one of these files on Unix, you may have to prefix the `~' (tilde) character with a (backslash) to prevent the shell from interpreting it as a special character.)
Shortcuts
As you become more familiar with NEdit, substitute the control and function keys shown on the right side of the menus for pulling down menus with the mouse.
Dialogs are also streamlined so you can enter information quickly and without using the mouse*. To move the keyboard focus around a dialog, use the tab and arrow keys. One of the buttons in a dialog is usually drawn with a thick, indented, outline. This button can be activated by pressing Return or Enter. The Cancel or Dismiss button can be activated by pressing escape. For example, to replace the string "thing" with "things" type:
<ctrl-r>thing<tab>things<return>
To open a file named "whole_earth.c", type:
<ctrl-o>who<return>
(how much of the filename you need to type depends on the other files in the directory). See the section called "Keyboard Shortcuts" for more details.
* Users who have set their keyboard focus mode to "pointer" should set "Popups Under Pointer" in the Default Settings menu to avoid the additional step of moving the mouse into the dialog.
To select text for copying, deleting, or replacing, press the left mouse button with the pointer at one end of the text you want to select, and drag it to the other end. The text will become highlighted. To select a whole word, double click (click twice quickly in succession). Double clicking and then dragging the mouse will select a number of words. Similarly, you can select a whole line or a number of lines by triple clicking or triple clicking and dragging. Quadruple clicking selects the whole file. After releasing the mouse button, you can still adjust a selection by holding down the shift key and dragging on either end of the selection. To delete the selected text, press delete or backspace. To replace it, begin typing.
To select a rectangle or column of text, hold the Ctrl key while dragging the mouse. Rectangular selections can be used in any context that normal selections can be used, including cutting and pasting, filling, shifting, dragging, and searching. Operations on rectangular selections automatically fill in tabs and spaces to maintain alignment of text within and to the right of the selection. Note that the interpretation of rectangular selections by Fill Paragraph is slightly different from that of other commands, the section titled "Shifting and Filling" has details.
The middle mouse button can be used to make an additional selection (called the secondary selection). As soon as the button is released, the contents of this selection will be copied to the insert position of the window where the mouse was last clicked (the destination window). This position is marked by a caret shaped cursor when the mouse is outside of the destination window. If there is a (primary) selection, adjacent to the cursor in the window, the new text will replace the selected text. Holding the shift key while making the secondary selection will move the text, deleting it at the site of the secondary selection, rather than copying it.
Selected text can also be dragged to a new location in the file using the middle mouse button. Holding the shift key while dragging the text will copy the selected text, leaving the original text in place. Holding the control key will drag the text in overlay mode.
Normally, dragging moves text by removing it from the selected position at the start of the drag, and inserting it at a new position relative to to the mouse. Dragging a block of text over existing characters, displaces the characters to the end of the selection. In overlay mode, characters which are occluded by blocks of text being dragged are simply removed. When dragging non-rectangular selections, overlay mode also converts the selection to rectangular form, allowing it to be dragged outside of the bounds of the existing text.
The section "Using the Mouse" sumarizes the mouse commands for making primary and secondary selections. Primary selections can also be made via keyboard commands, see "Keyboard Shortcuts".
The Find... and Replace... commands present dialogs for entering text for searching and replacing. These dialogs also allow you to choose whether you want the search to be sensitive to upper and lower case, or whether to use the standard Unix pattern matching characters (regular expressions). Searches begin at the current text insertion position.
Find Again and Replace Again repeat the last find or replace command without prompting for search strings. To selectively replace text, use the two commands in combination: Find Again, then Replace Again if the highlighted string should be replaced, or Find Again again to go to the next string.
Find Selection searches for the text contained in the current primary selection (see Selecting Text). The selected text does not have to be in the current editor window, it may even be in another program. For example, if the word dog appears somewhere in a window on your screen, and you want to find it in the file you are editing, select the word dog by dragging the mouse across it, switch to your NEdit window and choose Find Selection from the Search menu.
Find Incremental is yet another variation on searching, where every character typed triggers a new search. Incremental searching is generally the quickest way to find something in a file, because it gives you the immediate feedback of seeing how your search is progressing, so you never need to type more than the minimally sufficient search string to reach your target.
Searching Backwards
Holding down the shift key while choosing any of the search or replace commands from the menu (or using the keyboard shortcut), will search in the reverse direction. Users who have set the search direction using the buttons in the search dialog, may find it a bit confusing that Find Again and Replace Again don't continue in the same direction as the original search (for experienced users, consistency of the direction implied by the shift key is more important).
Selective Replacement
To replace only some occurrences of a string within a file, choose Replace... from the Search menu, enter the string to search for and the string to substitute, and finish by pressing the Find button. When the first occurrence is highlighted, use either Replace Again (^T) to replace it, or Find Again (^G) to move to the next occurrence without replacing it, and continue in such a manner through all occurrences of interest.
To replace all occurrences of a string within some range of text, select the range (see Selecting Text), choose Replace... from the Search menu, type the string to search for and the string to substitute, and press the "R. in Selection" button in the dialog. Note that selecting text in the Replace... dialog will unselect the text in the window.
There are many other methods for copying and moving text within NEdit windows and between NEdit and other programs. The most common such method is clicking the middle mouse button to copy the primary selection (to the clicked position). Copying the selection by clicking the middle mouse button in many cases is the only way to transfer data to and from many X programs. Holding the Shift key while clicking the middle mouse button moves the text, deleting it from its original position, rather than copying it. Other methods for transferring text include secondary selections, primary selection dragging, keyboard-based selection copying, and drag and drop. These are described in detail in the sections: "Selecting Text", "Using the Mouse", and "Keyboard Shortcuts".
If you don't have time to learn everything, you can get by adequately with just the left mouse button: Clicking the left button moves the cursor. Dragging with the left button makes a selection. Holding the shift key while clicking extends the existing selection, or begins a selection between the cursor and the mouse. Double or triple clicking selects a whole word or a whole line.
This section will make more sense if you also read the section called, "Selecting Text", which explains the terminology of selections, i.e. what is meant by primary, secondary, rectangular, etc.
Button and Modifier Key Summary
General meaning of mouse buttons and modifier keys:
Buttons
Button 1 (left) Cursor position and primary selection
Button 2 (middle) Secondary selections, and dragging and
copying the primary selection
Button 3 (right) Quick-access programmable menu and pan
scrolling
Modifier keys
Shift On primary selections, (left mouse button):
Extends selection to the mouse pointer
On secondary and copy operations, (middle):
Toggles between move and copy
Ctrl Makes selection rectangular or insertion
columnar
Alt* (on release) Exchange primary and secondary
selections.
Left Mouse Button
The left mouse button is used to position the cursor and to make primary selections.
Click Moves the cursor
Double Click Selects a whole word
Triple Click Selects a whole line
Quad Click Selects the whole file
Shift Click Adjusts (extends or shrinks) the
selection, or if there is no existing
selection, begins a new selection
between the cursor and the mouse.
Ctrl+Shift+ Adjusts (extends or shrinks) the
Click selection rectangularly.
Drag Selects text between where the mouse
was pressed and where it was released.
Ctrl+Drag Selects rectangle between where the
mouse was pressed and where it was
released.
Right Mouse Button
The right mouse button posts a programmable menu for frequently used commands.
Click/Drag Pops up the background menu (programmed
from Preferences -> Default Settings ->
Customize Menus -> Window Background).
Ctrl+Drag Pan scrolling. Scrolls the window
both vertically and horizontally, as if
you had grabbed it with your mouse.
Middle Mouse Button
The middle mouse button is for making secondary selections, and copying and dragging the primary selection.
Click Copies the primary selection to the
clicked position.
Shift+Click Moves the primary selection to the
clicked position, deleting it from its
original position.
Drag 1) Outside of the primary selection:
Begins a secondary selection.
2) Inside of the primary selection:
Moves the selection by dragging.
Ctrl+Drag 1) Outside of the primary selection:
Begins a rectangular secondary
selection.
2) Inside of the primary selection:
Drags the selection in overlay
mode (see below).
When the mouse button is released after creating a secondary selection:
No Modifiers If there is a primary selection,
replaces it with the secondary
selection. Otherwise, inserts the
secondary selection at the cursor
position.
Shift Move the secondary selection, deleting
it from its original position. If
there is a primary selection, the move
will replace the primary selection
with the secondary selection.
Otherwise, moves the secondary
selection to to the cursor position.
Alt* Exchange the primary and secondary
selections.
While moving the primary selection by dragging with the middle mouse button:
Shift Leaves a copy of the original
selection in place rather than
removing it or blanking the area.
Ctrl Changes from insert mode to overlay
mode (see below).
Escape Cancels drag in progress.
Overlay Mode: Normally, dragging moves text by removing it from the selected position at the start of the drag, and inserting it at a new position relative to to the mouse. When you drag a block of text over existing characters, the existing characters are displaced to the end of the selection. In overlay mode, characters which are occluded by blocks of text being dragged are simply removed. When dragging non-rectangular selections, overlay mode also converts the selection to rectangular form, allowing it to be dragged outside of the bounds of the existing text.
* The Alt key may be labeled Meta or Compose-Character on some keyboards. Some window managers, including default configurations of mwm, bind combinations of the Alt key and mouse buttons to window manager operations. In NEdit, Alt is only used on button release, so regardless of the window manager bindings for Alt-modified mouse buttons, you can still do the corresponding NEdit operation by using the Alt key AFTER the initial mouse press, so that Alt is held while you release the mouse button. If you find this difficult or annoying, you can re-configure most window managers to skip this binding, or you can re-configure NEdit to use a different key combination.
Menu Accelerators
Pressing the key combinations shown on the right of the menu items is a shortcut for selecting the menu item with the mouse. Some items have the shift key enclosed in brackets, such as [Shift]Ctrl+F. This indicates that the shift key is optional. In search commands, including the shift key reverses the direction of the search. In Shift commands, it makes the command shift the selected text by a whole tab stop rather than by single characters.
Menu Mnemonics
Pressing the Alt key in combination with one of the underlined characters in the menu bar pulls down that menu. Once the menu is pulled down, typing the underlined characters in a menu item (without the Alt key) activates that item. With a menu pulled down, you can also use the arrow keys to select menu items, and the Space or Enter keys to activate them.
Keyboard Shortcuts within Dialogs
One button in a dialog is usually marked with a thick indented outline. Pressing the Return or Enter key activates this button.
All dialogs have either a Cancel or Dismiss button. This button can be activated by pressing the Escape (or Esc) key.
Pressing the tab key moves the keyboard focus to the next item in a dialog. Within an associated group of buttons, the arrow keys move the focus among the buttons. Shift+Tab moves backward through the items.
Most items in dialogs have an underline under one character in their name. Pressing the Alt key along with this character, activates a button as if you had pressed it with the mouse, or moves the keyboard focus to the associated text field or list.
You can select items from a list by using the arrow keys to move the selection and space to select.
In file selection dialogs, you can type the beginning characters of the file name or directory in the list to select files
Labeled Function Keys
The labeled function keys on standard workstation and PC keyboards, like the arrows, and page-up and page-down, are active in NEdit, though not shown in the pull-down menus.
Holding down the control key while pressing a named key extends the scope of the action that it performs. For example, Home normally moves the insert cursor the beginning of a line. Ctrl+Home moves it to the beginning of the file. Backspace deletes one character, Ctrl+Backspace deletes one word.
Holding down the shift key while pressing a named key begins or extends a selection. Combining the shift and control keys combines their actions. For example, to select a word without using the mouse, position the cursor at the beginning of the word and press Ctrl+Shift+RightArrow. The Alt key modifies selection commands to make the selection rectangular.
Under X and Motif, there are several levels of translation between keyboard keys and the actions they perform in a program. The "Customizing NEdit", and "X Resources" sections of the Help menu have more information on this subject. Because of all of this configurability, and since keyboards and standards for the meaning of some keys vary from machine to machine, the mappings may be changed from the defaults listed below.
Modifier Keys (in general)
Ctrl Extends the scope of the action that the key
would otherwise perform. For example, Home
normally moves the insert cursor to the beginning
of a line. Ctrl+Home moves it to the beginning of
the file. Backspace deletes one character, Ctrl+
Backspace deletes one word.
Shift Extends the selection to the cursor position. If
there's no selection, begins one between the old
and new cursor positions.
Alt When modifying a selection, makes the selection
rectangular.
(For the effects of modifier keys on mouse button presses, see the section titled "Using the Mouse")
All Keyboards
Escape Cancels operation in progress: menu
selection, drag, selection, etc. Also
equivalent to cancel button in dialogs.
Backspace Delete the character before the cursor
Ctrl+BS Delete the word before the cursor
Arrows --
Left Move the cursor to the left one character
Ctrl+Left Move the cursor backward one word
(Word delimiters are settable, see
"Customizing NEdit", and "X Resources")
Right Move the cursor to the right one character
Ctrl+Right Move the cursor forward one word
Up Move the cursor up one line
Ctrl+Up Move the cursor up one paragraph.
(Paragraphs are delimited by blank lines)
Down Move the cursor down one line.
Ctrl+Down Move the cursor down one paragraph.
Ctrl+Return Return with automatic indent, regardless
of the setting of Auto Indent.
Shift+Return Return without automatic indent,
regardless of the setting of Auto Indent.
Ctrl+Tab Insert an ascii tab character, without
processing emulated tabs.
Alt+Ctrl+<c> Insert the control-code equivalent of
a key <c>
Ctrl+/ Select everything (same as Select
All menu item or ^A)
Ctrl+\ Unselect
Ctrl+U Delete to start of line
PC Standard Keyboard
Ctrl+Insert Copy the primary selection to the
clipboard (same as Copy menu item or ^C)
for compatibility with Motif standard key
binding
Shift+Ctrl+
Insert Copy the primary selection to the cursor
location.
Delete Delete the character before the cursor.
(Can be configured to delete the character
after the cursor, see "Customizing NEdit",
and "X Resources")
Ctrl+Delete Delete to end of line.
Shift+Delete Cut, remove the currently selected text
and place it in the clipboard. (same as
Cut menu item or ^X) for compatibility
with Motif standard key binding
Shift+Ctrl+
Delete Cut the primary selection to the cursor
location.
Home Move the cursor to the beginning of the
line
Ctrl+Home Move the cursor to the beginning of the
file
End Move the cursor to the end of the line
Ctrl+End Move the cursor to the end of the file
PageUp Scroll and move the cursor up by one page.
Ctrl+PageUp Scroll and move the cursor left by one
page.
PageDown Scroll and move the cursor down by one
page.
Ctrl+PageDown Scroll and move the cursor right by one
page.
F10 Make the menu bar active for keyboard
input (Arrow Keys, Return, Escape,
and the Space Bar)
Specialty Keyboards
On machines with different styles of keyboards, generally, text editing actions are properly matched to the labeled keys, such as Remove, Next-screen, etc.. If you prefer different key bindings, see the section titled "Key Binding" under the Customizing heading in the Help menu.
While shifting blocks of text is most important for programmers (See Features for Programming), it is also useful for other tasks, such as creating indented paragraphs.
To shift a block of text one tab stop to the right, select the text, then choose Shift Right from the Edit menu. Note that the accelerator keys for these menu items are Ctrl+9 and Ctrl+0, which correspond to the right and left parenthesis on most keyboards. Remember them as adjusting the text in the direction pointed to by the parenthesis character. Holding the Shift key while selecting either Shift Left or Shift Right will shift the text by one character.
It is also possible to shift blocks of text by selecting the text rectangularly, and dragging it left or right (and up or down as well). Using a rectangular selection also causes tabs within the selection to be recalculated and substituted, such that the non-whitespace characters remain stationary with respect to the selection.
Filling
Text filling using the Fill Paragraph command in the Edit menu is one of the most important concepts in NEdit. And it will be well worth your while to understand how to use it properly.
In plain text files, unlike word-processor files, there is no way to tell which lines are continuations of other lines, and which lines are meant to be separate, because there is no distinction in meaning between newline characters which separate lines in a paragraph, and ones which separate paragraphs from other text. This makes it impossible for a text editor like NEdit to tell parts of the text which belong together as a paragraph from carefully arranged individual lines.
In continuous wrap mode (Preferences -> Wrap -> Continuous), lines automatically wrap and unwrap themselves to line up properly at the right margin. In this mode, you simply omit the newlines within paragraphs and let NEdit make the line breaks as needed. Unfortunately, continuous wrap mode is not appropriate in the majority of situations, because files with extremely long lines are not common under Unix and may not be compatible with all tools, and because you can't achieve effects like indented sections, columns, or program comments, and still take advantage of the automatic wrapping.
Without continuous wrapping, paragraph filling is not entirely automatic. Auto-Newline wrapping keeps paragraphs lined up as you type, but once entered, NEdit can no longer distinguish newlines which join wrapped text, and newlines which must be preserved. Therefore, editing in the middle of a paragraph will often leave the right margin messy and uneven.
Since NEdit can't act automatically to keep your text lined up, you need to tell it explicitly where to operate, and that is what Fill Paragraph is for. It arranges lines to fill the space between two margins, wrapping the lines neatly at word boundaries. Normally, the left margin for filling is inferred from the text being filled. The first line of each paragraph is considered special, and its left indentation is maintained separately from the remaining lines (for leading indents, bullet points, numbered paragraphs, etc.). Otherwise, the left margin is determined by the furthest left non-whitespace character. The right margin is either the Wrap Margin, set in the preferences menu (by default, the right edge of the window), or can also be chosen on the fly by using a rectangular selection (see below).
There are three ways to use Fill Paragraph. The simplest is, while you are typing text, and there is no selection, simply select Fill Paragraph (or type Ctrl+J), and NEdit will arrange the text in the paragraph adjacent to the cursor. A paragraph, in this case, means an area of text delimited by blank lines.
The second way to use Fill Paragraph is with a selection. If you select a range of text and then chose Fill Paragraph, all of the text in the selection will be filled. Again, continuous text between blank lines is interpreted as paragraphs and filled individually, respecting leading indents and blank lines.
The third, and most versitile, way to use Fill Paragraph is with a rectangular selection. Fill Paragraph treats rectangular selections differently from other commands. Instead of simply filling the text inside the rectangular selection, NEdit interprets the right edge of the selection as the requested wrap margin. Text to the left of the selection is not disturbed (the usual interpretation of a rectangular selection), but text to the right of the selection is included in the operation and is pulled in to the selected region. This method enables you to fill text to an arbitrary right margin, without going back and forth to the wrap-margin dialog, as well as to exclude text to the left of the selection such as comment bars or other text columns.
While character set differences are the most obvious and pose the most challenge to portability, they affect nedit only indirectly via the same font and localization mechanisms common to all X applications. If your system is set up properly, you will probably never see character-set related problems in nedit. NEdit can not display Unicode text files, or any multi-byte character set.
The primary difference between an MS DOS format file and a Unix format file, is how the lines are terminated. Unix uses a single newline character. MS DOS uses a carriage-return and a newline. NEdit can read and write both file formats, but internally, it uses the single character Unix standard. NEdit auto-detects MS DOS format files based on the line termination at the start of the file. Files are judged to be DOS format if all of the first five line terminators, within a maximum range, are DOS-style. To change the format in which nedit writes a file from DOS to Unix or visa versa, use the Save As... command and check or un-check the MS DOS Format button.
Wrapping within text files can vary among individual users, as well as from system to system. Both Windows and MacOS make frequent use of plain text files with no implicit right margin. In these files, wrapping is determined by the tool which displays them. Files of this style also exist on Unix systems, despite the fact that they are not supported by all Unix utilities. To display this kind of file properly in NEdit, you have to select the wrap style called Continuous. Wrapping modes are discussed in the sections: Customizing -> Preferences, and Basic Operation -> Shifting and Filling.
The last and most minute of format differences is the terminating newline. NEdit, like vi and approximately half of Unix editors, enforces a final terminating newline on all of the files that it writes. NEdit does this because some Unix compilers and utilities require it, and fail in various ways on files which do not have it. Emacs does not enforce this rule. Users are divided on which is best.
Language Modes
When nedit initially reads a file, it attempts to determine whether the file is in one of the computer languages that it knows about. Knowing what language a file is written in allows NEdit to assign highlight patterns and smart indent macros, and to set language specific preferences like word delimiters, tab emulation, and auto-indent. Language mode can be recognized from both the file name and from the first 200 characters of content. Language mode recognition and language-specific preferences are configured in: Preferences -> Default Settings -> Language Modes....
You can set the language mode manually for a window, by selecting it from the menu: Preferences -> Language Modes.
Line Numbers
To find a particular line in a source file by line number, choose Goto Line #... from the Search menu. You can also directly select the line number text in the compiler message in the terminal emulator window (xterm, decterm, winterm, etc.) where you ran the compiler, and choose Goto Selected from the Search menu.
To find out the line number of a particular line in your file, turn on Statistics Line in the Preferences menu and position the insertion point anywhere on the line. The statistics line continuously updates the line number of the line containing the cursor.
Matching Parentheses
To help you inspect nested parentheses, brackets, braces, quotes, and other characters, NEdit has both an automatic parenthesis matching mode, and a Goto Matching command. Automatic parenthesis matching is activated when you type, or move the insertion cursor after a parenthesis, bracket, or brace. It momentarily highlights the matching character if that character is visible in the window. To find a matching character anywhere in the file, select it or position the cursor after it, and choose Goto Matching from the Search menu. If the character matches itself, such as a quote or slash, select the first character of the pair. NEdit will match {, (, [, <, ", ', `, /, and \. Holding the Shift key while typing the accelerator key (Shift+Ctrl+M, by default),will select all of the text between the matching characters.
Opening Included Files
The Open Selected command in the File menu understands the C preprocessor's #include syntax, so selecting an #include line and invoking Open Selected will generally find the file referred to, unless doing so depends on the settings of compiler switches or other information not available to NEdit.
Interface to Programming Tools
Integrated software development environments such as SGI's CaseVision and Centerline Software's Code Center, can be interfaced directly with NEdit via the client server interface. These tools allow you to click directly on compiler and runtime error messages and request NEdit to open files, and select lines of interest. The easiest method is usually to use the tool's interface for character-based editors like vi, to invoke nc, but programmatic interfaces can also be derived using the source code for nc.
There are also some simple compile/review, grep, ctree, and ctags browsers available in the NEdit contrib directory on ftp.fnal.gov.
Tabs are important for programming in languages which use indentation to show nesting, as short-hand for producing white-space for leading indents. As a programmer, you have to decide how to use indentation, and how or whether tab characters map to your indentation scheme.
Ideally, tab characters map directly to the amount of indent that you use to distinguish nesting levels in your code. Unfortunately, the Unix standard for interpretation of tab characters is eight characters (probably dating back to mechanical capabilities of the original teletype), which is usually too coarse for a single indent.
Most text editors, NEdit included, allow you to change the interpretation of the tab character, and many programmers take advantage of this, and set their tabs to 3 or 4 characters to match their programming style. In NEdit you set the hardware tab distance in Preferences -> Tabs... for the current window, or Preferences -> Default Settings -> Tabs... (general), or Preferences -> Default Settings -> Language Modes... (language-specific) to change the defaults for future windows.
Changing the meaning of the tab character makes programming much easier while you're in the editor, but can cause you headaches outside of the editor, because there is no way to pass along the tab setting as part of a plain-text file. All of the other tools which display, print, and otherwise process your source code have to be made aware of how the tabs are set, and must be able to handle the change. Non-standard tabs can also confuse other programmers, or make editing your code difficult for them if their text editors don't support changes in tab distance.
Emulated Tabs
An alternative to changing the interpretation of the tab character is tab emulation. In the Tabs... dialog(s), turning on Emulated Tabs causes the Tab key to insert the correct number of spaces and/or tabs to bring the cursor the next emulated tab stop, as if tabs were set at the emulated tab distance rather than the hardware tab distance. Backspacing immediately after entering an emulated tab will delete the fictitious tab as a unit, but as soon as you move the cursor away from the spot, NEdit will forget that the collection of spaces and tabs is a tab, and will treat it as separate characters. To enter a real tab character with "Emulate Tabs" turned on, use Ctrl+Tab.
It is also possible to tell NEdit not to insert ANY tab characters at all in the course of processing emulated tabs, and in shifting and rectangular insertion/deletion operations, for programmers who worry about the misinterpretation of tab characters on other systems.
Smart Indent
Smart Indent in this release must still be considered somewhat experimental. Smart indent macros are only available by default for C and C++, and while these can easily be configured for different default indentation distances, they may not conform to everyone's exact C programming style. Smart indent is programmed in terms of macros in the NEdit macro language which can be entered in: Preferences -> Default Settings -> Indent -> Program Smart Indent. Hooks are provided for intervening at the point that a newline is entered, either via the user pressing the Enter key, or through auto-wrapping; and for arbitrary type-in to act on specific characters typed.
To type a newline character without invoking smart-indent when operating in smart-indent mode, hold the Ctrl key while pressing the Return or Enter key.
Auto-Indent
With Indent set to Auto (the default), NEdit keeps a running indent. When you press the Return or Enter key, spaces and tabs are inserted to line up the insert point under the start of the previous line. Ctrl+Return in auto-indent mode acts like a normal Return, With auto-indent turned off, Ctrl+Return does indentation.
Block Indentation Adjustment
The Shift Left and Shift Right commands as well as rectangular dragging can be used to adjust the indentation for several lines at once. To shift a block of text one character to the right, select the text, then choose Shift Right from the Edit menu. Note that the accelerator keys for these menu items are Ctrl+9 and Ctrl+0, which correspond to the right and left parenthesis on most keyboards. Remember them as adjusting the text in the direction pointed to by the parenthesis character. Holding the Shift key while selecting either Shift Left or Shift Right will shift the text by one tab stop (or by one emulated tab stop if tab emulation is turned on). The help section "Shifting and Filling" under "Basic Operation" has details.
To use syntax highlighting in NEdit, select Highlight Syntax in the Preferences menu. If NEdit recognizes the computer language that you are using, and highlighting rules (patterns) are available for that language, it will highlight your text, and maintain the highlighting, automatically, as you type.
If NEdit doesn't correctly recognize the type of the file you are editing, you can manually select a language mode from Language Modes in the Preferences menu. You can also program the method that NEdit uses to recognize language modes in Preferences -> Default Settings -> Language Modes....
If no highlighting patterns are available for the language that you want to use, you can create new patterns relatively quickly. The Help section "Highlighting Patterns" under "Customizing", has details.
If you are satisfied with what NEdit is highlighting, but would like it to use different colors or fonts, you can change these by selecting Preferences -> Default Settings -> Syntax Highlighting -> Text Drawing Styles. Highlighting patterns are connected with font and color information through a common set of styles so that colorings defined for one language will be similar across others, and patterns within the same language which are meant to appear identical can be changed in the same place. To understand which styles are used to highlight the language you are interested in, you may need to look at "Highlighting Patterns" section, as well.
Syntax highlighting is CPU intensive, and under some circumstances can affect NEdit's responsiveness. If you have a particularly slow system, or work with very large files, you may not want to use it all of the time. Syntax highlighting introduces two kinds of delays. The first is an initial parsing delay, proportional to the size of the file. This delay is also incurred when pasting large sections of text, filtering text through shell commands, and other circumstances involving changes to large amounts of text. The second kind of delay happens when text which has not previously been visible is scrolled in to view. Depending on your system, and the highlight patterns you are using, this may or may not be noticeable. A typing delay is also possible, but unlikely if you are only using the built-in patterns.
nedit -tags tags
NEdit can also be set to load a tags file automatically when it starts up. Setting the X resource nedit.tagFile to the name of a tag file tells NEdit to look for that file at startup time (see Customizing NEdit). The file name can be either a complete path name, in which case NEdit will always load the same tags file, or a file name without a path or with a relative path, in which case NEdit will load it starting from the current directory. The second option allows you to have different tags files for different projects, each automatically loaded depending on the directory you're in when you start NEdit. Setting the name to "tags" is an obvious choice since this is the name that ctags uses.
To unload a tags file, select "Un-load Tags File" from the File menu and choose from the list of tags files. NEdit will keep track of tags file updates by checking the timestamp on the files, and automatically update the tags cache.
To find the definition of a function or data structure once a tags file is loaded, select the name anywhere it appears in your program (see Selecting Text) and choose "Find Definition" from the Search menu.
A regex is a specification of a pattern to be matched in the searched text. This pattern consists of a sequence of tokens, each being able to match a single character or a sequence of characters in the text, or assert that a specific position within the text has been reached (the latter is called an anchor.) Tokens (also called atoms) can be modified by adding one of a number of special quantifier tokens immediately after the token. A quantifier token specifies how many times the previous token must be matched (see below.)
Tokens can be grouped together using one of a number of grouping constructs, the most common being plain parentheses. Tokens that are grouped in this way are also collectively considered to be a regex atom, since this new larger atom may also be modified by a quantifier.
A regex can also be organized into a list of alternatives by separating each alternative with pipe characters, `|'. This is called alternation. A match will be attempted for each alternative listed, in the order specified, until a match results or the list of alternatives is exhausted (see "Alternation" below.)
The Dot Meta Character
If an un-escaped dot (`.') appears in a regex, it means to match any character exactly once. By default dot will not match a newline character, but this behavior can be changed (see help topic "RegEx Parenthetical Constructs", item "Matching Newlines".)
Character Classes
A character class, or range, matches exactly one character of text, but the candidates for matching are limited to those specified by the class. Classes come in two flavors as described below:
[...] Regular class, match only characters listed.
[^...] Negated class, match only characters NOT listed.
As with the dot token, by default negated character classes do not match newline, but can be made to do so.
The characters that are considered special within a class specification are different than the rest of regex syntax as follows. If the first character in a class is the `]' character (second character if the first character is `^') it is a literal character and part of the class character set. This also applies if the first or last character is `-'. Outside of these rules, two characters separated by `-' form a character range which includes all the characters between the two characters as well. For example, `[^f-j]' is the same as `[^fghij]' and means to match any character that is not `f', `g', `h', `i', or `j'.
Anchors
Anchors are assertions that you are at a very specific position within the search text. NEdit regular expressions support the following anchor tokens:
^ Beginning of line
$ End of line
< Left word boundary
> Right word boundary
\B Not a word boundary
Note that the \B token ensures that the left and right characters are both delimiter characters, or that both left and right characters are non-delimiter characters. Currently word anchors check only one character, e.g. the left word anchor `<' only asserts that the left character is a word delimiter character. Similarly the right word anchor checks the right character.
Quantifiers
Quantifiers specify how many times the previous regular expression atom may be matched in the search text. Some quantifiers can produce a large performance penalty, and can in some instances completely lock up NEdit. To prevent this, avoid nested quantifiers, especially those of the maximal matching type (see below.)
The following quantifiers are maximal matching, or "greedy", in that they match as much text as possible.
* Match zero or more
+ Match one or more
? Match zero or one
The following quantifiers are minimal matching, or "lazy", in that they match as little text as possible.
*? Match zero or more
+? Match one or more
?? Match zero or one
One final quantifier is the counting quantifier, or brace quantifier. It takes the following basic form:
{min,max} Match from `min' to `max' times the
previous regular expression atom.
If `min' is omitted, it is assumed to be zero. If `max' is omitted, it is assumed to be infinity. Whether specified or assumed, `min' must be less than or equal to `max'. Note that both `min' and `max' are limited to 65535. If both are omitted, then the construct is the same as `*'. Note that `{,}' and `{}' are both valid brace constructs. A single number appearing without a comma, e.g. `{3}' is short for the `{min,min}' construct, or to match exactly `min' number of times.
The quantifiers `{1}' and `{1,1}' are accepted by the syntax, but are optimized away since they mean to match exactly once, which is redundant information. Also, for efficiency, certain combinations of `min' and `max' are converted to either `*', `+', or `?' as follows:
{} {,} {0,} *
{1,} +
{,1} {0,1} ?
Note that {0} and {0,0} are meaningless and will generate an error message at regular expression compile time.
Brace quantifiers can also be "lazy". For example {2,5}? would try to match 2 times if possible, and will only match 3, 4, or 5 times if that is what is necessary to achieve an overall match.
Alternation
A series of alternative patterns to match can be specified by separating them with vertical pipes, `|'. An example of alternation would be `a|be|sea'. This will match `a', or `be', or `sea'. Each alternative can be an arbitrarily complex regular expression. The alternatives are attempted in the order specified. An empty alternative can be specified if desired, e.g. `a|b|'. Since an empty alternative can match nothingness (the empty string), this guarantees that the expression will match.
Comments
Comments are of the form `(?#
In a regular expression (regex), most ordinary characters match themselves.
For example, `ab%' would match anywhere `a' followed by `b' followed by
`%' appeared in the text. However, there are some special characters that are
difficult or impossible to type. Many of these characters have escape sequences
(simple characters preceded by `\') assigned to represent them.
NEdit recognizes the following special character escape sequences:
Escaped Meta Characters
Characters that have special meaning to the regex syntax are called meta
characters. NEdit provides the following escape sequences so that characters
that are used by the regex syntax can be specified as ordinary characters and
not interpreted as meta characters.
Octal and Hex Escape Sequences
Any ASCII (or EBCDIC) character, except null, can be specified by using
either an octal escape or a hexadecimal escape, each beginning with \0 or \x
(or \X) respectively. For example, \052 and \X2A both specify the `*'
character. Escapes for null (\00 or \x0) are not valid and will generate an
error message. Also, any escape that exceeds \0377 or \xFF will either cause
an error or have any additional character(s) interpreted literally. For
example, \0777 will be interpreted as \077 (a `?' character) followed by `7'
since \0777 is greater than \0377.
An invalid digit will also end an octal or hexadecimal escape. For example,
\091 will cause an error since `9' is not within an octal escape's range of
allowable digits (0-7) and truncation before the `9' yields \0 which is
invalid.
Shortcut Escapes
NEdit defines some escape sequences that are handy shortcuts for commonly
used character classes.
\D, \L, \S, and \W are the same as the lowercase versions except that the
resulting character class is negated. For example, \d is equivalent to
`[0-9]', while \D is equivalent to `[^0-9]'.
These escape sequences can also be used within a character class. For
example, `[\l_]' is the same as `[a-zA-Z_]'. The escape sequences for
special characters, and octal and hexadecimal escapes are also valid within a
class.
Word Delimiter Tokens
Although not strictly a character class, the following escape sequences
behave similarly to character classes:
The `\y' token matches any single character that is one of the characters
that NEdit recognizes as a word delimiter character, while the `\Y' token
matches any character that is NOT a word delimiter character. Word delimiter
characters are dynamic in nature, meaning that the user can change them through
preference settings. For this reason, they must be handled differently by the
regular expression engine. As a consequence of this, `\y' and `\Y' can not be
used within a character class specification.
Capturing Parentheses are of the form `(
Non-Capturing Parentheses
Non-Capturing Parentheses are of the form `(?:
Positive Look-Ahead
Positive look-ahead constructs are of the form `(?=
One application of positive look-ahead is the manual implementation of a
first character discrimination optimization. You can include a positive
look-ahead that contains a character class which lists every character that
the following (potentially complex) regular expression could possibly start
with. This will quickly filter out match attempts that can not possibly
succeed.
Negative Look-Ahead
Negative look-ahead takes the form `(?!
Case Sensitivity
There are two parenthetical constructs that control case sensitivity:
Regular expressions are case sensitive by default, i.e `(?I
Matching Newlines
NEdit regular expressions by default handle the matching of newlines in a way
that should seem natural for most editing tasks. There are situations,
however, that require finer control over how newlines are matched by some
regular expression tokens.
By default, NEdit regular expressions will NOT match a newline character for
the following regex tokens: dot (`.'); a negated character class (`[^...]');
and the following shortcuts for character classes:
The matching of newlines can be controlled for the `.' token, negated
character classes, and the `\s' and `\S' shortcuts by using one of the
following parenthetical constructs:
`(?N
Notes on New Parenthetical Constructs
Except for plain parentheses, none of the parenthetical constructs capture
text. If that is desired, the construct must be wrapped with capturing
parentheses, e.g. `((?i
Back References
Backreferences allow you to match text captured by a set of capturing
parenthesis at some latter position in your regular expression. A
backreference is specified using a single backslash followed by a single
digit from 1 to 9 (example: \3). Backreferences have similar syntax to
substitutions (see below), but are different from substitutions in that they
appear within the regular expression, not the substitution string. The number
specified with a backreference identifies which set of text capturing
parentheses the backreference is associated with. The text that was most
recently captured by these parentheses is used by the backreference to
attempt a match. As with substitutions, open parentheses are counted from
left to right beginning with 1. So the backreference `\3' will try to match
another occurrence of the text most recently matched by the third set of
capturing parentheses. As an example, the regular expression `(\d)\1' could
match `22', `33', or `00', but wouldn't match `19' or `01'.
A backreference must be associated with a parenthetical expression that is
complete. The expression `(\w(\1))' contains an invalid backreference since
the first set of parentheses are not complete at the point where the
backreference appears.
Substitution
Substitution strings are used to replace text matched by a set of capturing
parentheses. The substitution string is mostly interpreted as ordinary text
except as follows.
The escape sequences described above for special characters, and octal and
hexadecimal escapes are treated the same way by a substitution string. When
the substitution string contains the `&' character, NEdit will substitute the
entire string that was matched by the `Find...' operation. Any of the first
nine sub-expressions of the match string can also be inserted into the
replacement string. This is done by inserting a `\' followed by a digit from
1 to 9 that represents the string matched by a parenthesized expression
within the regular expression. These expressions are numbered left-to-right
in order of their opening parentheses.
The capitalization of text inserted by `&' or `\1', `\2', ... `\9' can be
altered by preceding them with `\U', `\u', `\L', or `\l'. `\u' and `\l'
change only the first character of the inserted entity, while `\U' and `\L'
change the entire entity to upper or lower case, respectively.
Regular expression substitution can be used to program automatic editing
operations. For example, the following are search and replace strings to find
occurrences of the `C' language subroutine `get_x', reverse the first and
second parameters, add a third parameter of NULL, and change the name to
`new_get_x':
Ambiguity
If a regular expression could match two different parts of the text, it will
match the one which begins earliest. If both begin in the same place but
match different lengths, or match the same length in different ways, life
gets messier, as follows.
In general, the possibilities in a list of alternatives are considered in
left-to-right order. The possibilities for `*', `+', and `?' are considered
longest-first, nested constructs are considered from the outermost in, and
concatenated constructs are considered leftmost-first. The match that will be
chosen is the one that uses the earliest possibility in the first choice that
has to be made. If there is more than one choice, the next will be made in
the same manner (earliest possibility) subject to the decision on the first
choice. And so forth.
For example, `(ab|a)b*c' could match `abc' in one of two ways. The first
choice is between `ab' and `a'; since `ab' is earlier, and does lead to a
successful overall match, it is chosen. Since the `b' is already spoken for,
the `b*' must match its last possibility, the empty string, since it must
respect the earlier choice.
In the particular case where no `|'s are present and there is only one `*',
`+', or `?', the net effect is that the longest possible match will be
chosen. So `ab*', presented with `xabbbby', will match `abbbb'. Note that
if `ab*' is tried against `xabyabbbz', it will match `ab' just after `x', due
to the begins-earliest rule. (In effect, the decision on where to start the
match is the first choice to be made, hence subsequent choices must respect
it even if this leads them to less-preferred alternatives.)
References
An excellent book on the care and feeding of regular expressions is
Filter Selection... prompts you for a Unix command to use to process the
currently selected text. The output from this command replaces the contents
of the selection.
Execute Command... prompts you for a Unix command and replaces the current
selection with the output of the command. If there is no selection, it
deposits the output at the current insertion point.
Execute Command Line uses the position of the cursor in the window to
indicate a line to execute as a shell command line. The cursor may be
positioned anywhere on the line. This command allows you to use an NEdit
window as an editable command window for saving output and saving commands
for re-execution.
The X resource called nedit.shell (See "Customizing NEdit") determines which
Unix shell is used to execute commands. The default value for this resource
is /bin/csh.
Note that only keyboard and menu commands are recorded, not mouse clicks or
mouse movements since these have no absolute point of reference, such as
cursor or selection position. When you do a mouse-based operation in learn
mode, NEdit will beep (repeatedly) to remind you that the operation was not
recorded.
Learn mode is also the quickest and easiest method for writing macros. The
dialog for creating macro commands contains a button labeled "Paste Learn /
Replay Macro", which will deposit the last sequence learned into the body of
the macro.
Repeating Actions and Learn/Replay Sequences
You can repeat the last (keyboard-based) command, or learn/replay sequence
with the Repeat... command in the Macro menu. To repeat an action, first do
the action (i.e. insert a character, do a search, move the cursor), then
select Repeat..., decide how or how many times you want it repeated, and
click OK. For example, to move down 30 lines through a file, you could type:
<Down Arrow> Ctrl+, 29 <Return>. To repeat a learn/replay sequence, first
learn it, then select Repeat..., click on Learn/Replay and how you want it
repeated, then click OK.
If the commands you are repeating advance the cursor through the file, you
can also repeat them within a range of characters, or from the current cursor
position to the end of the file. To iterate over a range of characters, use
the primary selection (drag the left mouse button over the text) to mark the
range you want to operate on, and select "In Selection" in the Repeat dialog.
When using In "Selection" or "To End" with a learned sequence, try to do
cursor movement as the last step in the sequence, since testing of the cursor
position is only done at the end of the sequence execution. If you do cursor
movement first, for example searching for a particular word then doing a
modification, the position of the cursor won't be checked until the sequence
has potentially gone far beyond the end of your desired range.
It's easy for a repeated command to get out of hand, and you can easily
generate an infinite loop by using range iteration on a command which doesn't
progress. To cancel a repeating command in progress, type Ctrl+. (period),
or select Cancel Macro from the Macro menu.
NEdit's macro language is a simple interpreter with integer arithmetic,
dynamic strings, and C-style looping constructs (very similar to the
procedural portion of the Unix awk program). From the macro language, you
can call the same action routines which are bound to keyboard keys and menu
items, as well additional subroutines for accessing and manipulating editor
data, which are specific to the macro language (these are listed in the
sections titled "Macro Subroutines", and "Action Routines").
SYNTAX
An NEdit macro language program consists of a list of statements, each
terminated by a newline. Groups of statements which are executed together
conditionally, such as the body of a loop, are surrounded by curly braces
"{}".
Blank lines and comments are also allowed. Comments begin with a "#" and end
with a newline, and can appear either on a line by themselves, or at the end
of a statement.
Statements which are too long to fit on a single line may be split across
several lines, by placing a backslash "\" character at the end of each line
to be continued.
DATA TYPES
The NEdit macro language recognizes only two data types, dynamic character
strings, and integer values. In general strings and integers can be used
interchangeably. If a string represents an integer value, it can be used as
an integer. Integers can be compared and concatenated with strings.
Integer Constants
Integers are non-fractional numbers in the range of -2147483647 to
2147483647. Integer constants must be in decimal. For example:
Character String Constants
Character string constants are enclosed in double quotes. For example:
Strings may also include C-language style escape sequences:
For example, to send output to the terminal from which nedit was started, a
newline character is neccessary because, like printf, t_print requires
explicit newlines, and also buffers its output on a per-line basis:
VARIABLES
Variable names must begin either with a letter (local variables), or a $
(global variables). Beyond the first character, variables may also contain
numbers and underscores `_'. Variables are called in to existence just by
setting them (no explicit declarations are necessary).
Local variables are limited in scope to the subroutine (or menu item
definition) in which they appear. Global variables are accessible from all
routines, and their values persist beyond the call which created them, until
reset.
Built-in Variables
NEdit has a number of permanently defined variables, which are used to access
global editor information and information about the the window in which the
macro is executing. These are listed along with the built in functions in
the section titled "Macro Subroutines".
FUNCTIONS and SUBROUTINES
The syntax of a function or subroutine call is:
where arg1, arg2, etc. represent up to 9 argument values which are passed to
the routine being called. A function or subroutine call can be on a line by
itself, as above, or if it returns a value, can be invoked within a character
or numeric expression:
Arguments are passed by value. This means that you can not return values via
the argument list, only through the function value or indirectly through
agreed-upon global variables.
Built-in Functions
NEdit has a wide range of built in functions which can be called from the
macro language. These routines are divided into two classes, macro-language
functions, and editor action routines. Editor action routines are more
flexible, in that they may be called either from the macro language, or bound
directly to keys via translation tables. They are also limited, however, in
that they can not return values. Macro language routines can return values,
but can not be bound to keys in translation tables.
Nearly all of the built-in subroutines operate on an implied window, which is
initially the window from which the macro was started. To manipulate the
contents of other windows, use the focus_window subroutine to change the
focus to the ones you wish to modify. focus_window can also be used to
iterate over all of the currently open windows, using the special keyword
names, "last" and "next".
For backwards compatibility, hyphenated action routine names are allowed, and
most of the existing action routines names which contain underscores have an
equivalent version containing hyphens ('-') instead of underscores. Use of
these names is discouraged. The macro parser resolves the ambiguity between
'-' as the subtraction/negation operator, and - as part of an action routine
name by assuming subtraction unless the symbol specifically matches an action
routine name.
User Defined Functions
Users can define their own macro subroutines, using the define keyword:
Macro definitions can not appear within other definitions, or within macro
menu item definitions (usually they are found in the .neditmacro file).
The arguments with which a user-defined subroutine or function was invoked,
are presented as $1, $2, ... , $9. The number of arguments can be read from
$n_args.
To return a value from a subroutine, and/or to exit from the subroutine
before the end of the subroutine body, use the return statement:
OPERATORS AND EXPRESSIONS
Operators have the same meaning and precedence that they do in C, except for
^, which raises a number to a power (y^x means y to the x power), rather than
bitwise exclusive OR. The table below lists operators in decreasing order of
precedence.
The order in which operands are evaluated in an expression is undefined,
except for && and ||, which like C, evaluate operands left to right, but stop
when further evaluation would no longer change the result.
Numerical Operators
The numeric operators supported by the NEdit macro language are listed below:
Increment (++) and decrement (--) operators can also be appended or prepended
to variables within an expression. Prepended increment/decrement operators
act before the variable is evaulated. Appended increment/decrement operators
act after the variable is evaluated.
Logical and Comparison Operators
Logical operations produce a result of 0 (for false) or 1 (for true). In a
logical operation, any non-zero value is recognized to mean true. The
logical and comparison operators allowed in the NEdit macro language are
listed below:
Character String Operators
The "operator" for concatenating two strings is the absence of an operator.
Adjoining character strings with no operator in between means concatenation:
Comparison between character strings is done with the == and != operators,
(as with integers). There are a number of useful built-in routines for
working with character strings, which are listed in the section called
"Macro Subroutines".
LOOPING AND CONDITIONALS
NEdit supports looping constructs: for and while, and conditional statements:
if and else, with essentially the same syntax as C:
<body>, as in C, can be a single statement, or a list of statements enclosed
in curly braces ({}). <condition> is an expression which must evaluate to
true for the statements in <body> to be executed. for loops may also contain
initialization statements, <init>, executed once at the beginning of the
loop, and increment/decrement statements (or any arbitrary statement), which
are executed at the end of the loop, before the condition is evaluated again.
Examples:
Loops may contain break and continue statements. A break statement causes an
exit from the innermost loop, a continue statement transfers control to the
end of the loop.
Built-in Subroutines
Actions Representing Menu Commands
The actions representing menu commands are named the same as the menu item
with punctuation removed, all lower case, and underscores replacing spaces.
Without the `_dialog` suffix, commands which normally prompt the user for
information, instead take the information from the routine's arguments (see
below). To present a dialog and ask the user for input, rather than
supplying it in via arguments, use the actions with the `_dialog` suffix.
Menu Action Routine Arguments
Arguments are text strings enclosed in quotes. Below are the menu action
routines which take arguments. Optional arguments are inclosed in [].
Some notes on argument types above:
Keyboard-Only Actions
Arguments to Keyboard Action Routines
In addition to the arguments listed in the call descriptions, any routine
involving cursor movement can take the argument "extend", meaning, adjust the
primary selection to the new cursor position. Routines which take the
"extend" argument as well as mouse dragging operations for both primary and
secondary selections can take the optional keyword "rect", meaning, make the
selection rectangular.
User defined commands can be added to NEdit's Shell, Macro, and window
background menus. Dialogs for creating items in these menus can be found
under Customize Menus in the Default Settings sub menu of the Preferences
menu.
For users who depend on NEdit every day and want to tune every excruciating
detail, there are also X resources for tuning a vast number of such details,
down to the color of each individual button. See the section "X Resources"
for more information, as well as a list of selected resources.
The most common reason customizing your X resources for NEdit, however, is
key binding. While limited key binding can be done through Preferences
settings (Preferences -> Default Settings -> Customize Menus), you can really
only add keys this way, and each key must have a corresponding menu item.
Any significant changes to key binding should be made via the Translations
resource and menu accelerator resources. The sections titled "Key Binding"
and "X Resources" have more information.
Preferences Menu
Preferences -> Default Settings Menu
Options in the Preferences -> Default Settings menu have the same meaning as
those in the top-level Preferences menu, except that they apply to future
NEdit windows and future NEdit sessions if saved with the Save Defaults
command. Additional options which appear in this menu are:
Changing Font(s)
The font used to display text in NEdit is set under Preferences -> Text Font
(for the current window), or Preferences -> Default Settings Text Font (for
future windows). These dialogs also allow you to set fonts for syntax
highlighting. If you don't intend to use syntax highlighting, you can ignore
most of the dialog, and just set the field labeled Primary Font.
Unless you are absolutely certain about the types of files that you will be
editing with NEdit, you should choose a fixed-spacing font. Many, if not
most, plain-text files are written expecting to be viewed with fixed
character spacing, and will look wrong with proportional spacing. NEdit's
filling, wrapping, and rectangular operations will also work strangely if you
choose a proportional font.
Note that in the font browser (the dialog brought up by the Browse...
button), the subset of fonts which are shown is narrowed depending on the
characteristics already selected. It is therefore important to know that you
can unselect characteristics from the lists by clicking on the selected items
a second time.
Fonts for syntax highlighting should ideally match the primary font in both
height and spacing. A mismatch in spacing will result in similar distortions
as choosing a proportional font: column alignment will sometimes look wrong,
and rectangular operations, wrapping, and filling will behave strangely. A
mismatch in height will cause windows to re-size themselves slightly when
syntax highlighting is turned on or off, and increase the inter- line spacing
of the text. Unfortunately, on some systems it is hard to find sets of fonts
which match exactly in height.
Customizing Menus
You can add or change items in the Shell, Macro, and window background menus
under Preferences -> Default Settings -> Customize Menus. When you choose
one of these, you will see a dialog with a list of the current
user-configurable items from the menu on the left. To change an existing
item, select it from the list, and its properties will appear in the
remaining fields of the dialog, where you may change them. Selecting the
item "New" from the list allows you to enter new items in the menu.
Hopefully most of the characteristics are self explanatory, but here are a
few things to note:
Accelerator keys are keyboard shortcuts which appear on the right hand side
of the menus, and allow you avoid pulling down the menu and activate the
command with a single keystroke. Enter accelerators by typing the keys
exactly as you would to activate the command.
Mnemonics are a single letter which should be part of the menu item name,
which allow users to traverse and activate menu items by typing keys when the
menu is pulled down.
In the Shell Command field of the Shell Commands dialog, the % character
expands to the name (including directory path) of the file in the window. To
include a % character in the command, use %%.
The Menu Entry field can contain special characters for constructing
hierarchical sub-menus, and for making items which appear only in certain
language modes. The right angle bracket character ">" creates a sub-menu.
The name of the item itself should be the last element of the path formed
from successive sub-menu names joined with ">". Menu panes are called in to
existence simply by naming them as part of a Menu Entry name. To put several
items in the same sub-menu, repeat the same hierarchical sequence for each.
For example, in the Macro Commands dialog, two items with menu entries: a>b>c
and a>b>d would create a single sub menu under the macro menu called "a",
which would contain a single sub-menu, b, holding the actual items, c and d:
To qualify a menu entry with a language mode, simply add an at-sign "@" at
the end of the menu command, followed (no space) by a language mode name. To
make a menu item which appears in several language modes, append additional
@s and language mode names. For example, an item with the menu entry:
would appear only in C and C++ language modes, and:
would appear only in C++ mode.
Menu items with no qualification appear in all language modes.
If a menu item is followed by the single language qualification "@*", that
item will appear only if there are no applicable language-specific items of
the same name in the same submenu. For example, if you have the following
three entries in the same menu:
The first will be available when the language mode is C or C++, the second
when the language mode is Java, and for all other language modes (including
the "Plain" non-language mode). If the entry:
also exists, this will always appear, meaning that the menu will always have
two "Make Prototypes" entries, whatever the language mode.
Sharing Customizations with Other NEdit Users
If you have written macro or shell menu commands, highlight patterns, or
smart-indent macros that you want to share with other NEdit users, you can
make a file which they can load into their nedit environment.
To load such a file, start nedit with the command:
In the new nedit session, verify that the imported patterns or macros do what
you want, then select Preferences -> Save Defaults. Saving incorporates the
changes into your own .nedit file, so the next time you run nedit, you will
not have to import the distribution file.
Loading a customization file is automated, but creating one is not. To
produce a file to be imported by other users, you must make a copy of your
own .nedit file, and edit it, by hand, to remove everything but the few items
of interest to the recipient. Leave only the individual resource(s), and
within those resources, only the particular macro, pattern, style, etc, that
you wish to exchange. For example, to share a highlighting pattern set, you
would include the patterns, any new styles you added, and language mode
information only if the patterns are intended to support a new language
rather than updating an existing one. For example:
Resources are in the format of X resource files, but the format of text
within multiple-item resources like highlight patterns, language modes,
macros, styles, etc., are private to NEdit. Each resource is a string which
ends at the first newline character not escaped with \, so you must be
careful about how you treat ends of lines. While you can generally just cut
and paste indented sections, if something which was originally in the middle
of a resource string is now at the end, you must remove the \ line
continuation character(s) so it will not join the next line into the
resource. Conversely, if something which was originally at the end of a
resource is now in the middle, you'll have to add continuation character(s)
to make sure that the resource string is properly continued from beginning to
end, and possibly newline character(s) (\n) to make sure that it is properly
separated from the next item.
RegEx Escape Sequences
Special Control Characters
\a alert (bell)
\b backspace
\e ASCII escape character (***)
\f form feed (new page)
\n newline
\r carriage return
\t horizontal tab
\v vertical tab
*** For environments that use the EBCDIC character set,
when compiling NEdit set the EBCDIC_CHARSET compiler
symbol to get the EBCDIC equivalent escape
character.)
\( \) \- \[ \] \< \> \{ \}
\. \| \^ \$ \* \+ \? \& \\
\d digits 0-9
\l letters a-z and A-Z
\s whitespace \t, \r, \v, \f, and space
\w word characters a-z, A-Z, 0-9, and underscore, `_'
\y Word delimiter character
\Y Not a word delimiter character
RegEx Parenthetical Constructs
Capturing Parentheses
(?i<regex>) Case insensitive; `AbcD' and `aBCd' are
equivalent.
(?I<regex>) Case sensitive; `AbcD' and `aBCd' are
different.
`\d', `\D', `\l', `\L', `\s', `\S', `\w', `\W', `\Y'
(?n<regex>) `.', `[^...]', `\s', `\S' match newlines
(?N<regex>) `.', `[^...]', `\s', `\S' don't match
newlines
RegEx Advanced Topics
Substitutions
Search string: `get_x *\( *([^ ,]*), *([^\)]*)\)'
Replace string: `new_get_x(\2, \1, NULL)'
"Mastering Regular Expressions"
Jeffrey E. F. Friedl
(c) 1997, O'Reilly & Associates
ISBN 1-56592-257-3
RegEx Examples
The following are regular expression examples which will match:
^.*$
^$
\s+
(?n\s+)
(?n\s*?\n\s*)
(?:\d{1,3}(?:\.\d{1,3}){3})
[ACDF-IK-PR-W][A-Z]
(?:http://)?www\.\S+
(?i(?n<(\S+)\s+\1>))
<[A-Z][^a-z\s]*>
Shell Commands and Filters
The Shell menu (Unix versions only) allows you to execute Unix shell commands
from within NEdit. You can add items to the menu to extend NEdit's command
set or to incorporate custom automatic editing features using shell commands
or editing languages like awk and sed. To add items to the menu, select
Preferences -> Default Settings Customize Menus -> Shell Menu. NEdit comes
pre-configured with a few useful Unix commands like spell and sort, but we
encourage you to add your own custom extensions.
Learn/Replay
Selecting Learn Keystrokes from the Macro menu puts NEdit in learn mode. In
learn mode, keystrokes and menu commands are recorded, to be played back
later, using the Replay Keystrokes command, or pasted into a macro in the
Macro Commands dialog of the Default Settings menu in Preferences.
Macro Language
Macros can be called from Macro menu commands, window background menu
commands, within the smart-indent framework, and from the .neditmacro file.
Macro menu and window background menu commands are defined under Preferences
-> Default Settings -> Customize Menus. Help on creating items in these
menus can be found in the section, Help -> Customizing -> Preferences. The
.neditmacro file is a file of macro commands and definitions which you can
create in your home directory, and which NEdit will automatically load when
it is first started.
a = -1
b = 1000
a = "a string"
dialog("Hi there!", "Dismiss")
\\ Backslash \t Tab \f Form feed
\" Double quote \b Backspace \a Alert
\n Newline \r Carriage return \v Vertical tab
t_print("a = " a "\n")
function_name(arg1, arg2, ...)
a = fn1(b, c) + fn2(d)
dialog("fn3 says: " fn3())
define subroutine_name {
< body of subroutine >
}
return <value to return>
Operators Associativity
()
^ right to left
- ! ++ -- (unary)
* / % left to right
+ - left to right
> >= < <= == != left to right
& left to right
| left to right
&& left to right
|| left to right
(concatenation) left to right
= += -= *= /= %=, &= |= right to left
+ addition
- subtraction or negation
* multiplication
/ division
% modulo
^ power
& bitwise and
| bitwise or
&& logical and
|| logical or
! not
> greater
< less
>= greater or equal
<= less or equal
== equal (integers and/or strings)
!= not equal (integers and/or strings)
d = a b "string" c
t_print("the value of a is: " a)
for (<init>, ...; <condition>; <increment>, ...) <body>
while (<condition>) <body>
if (<condition>) <body>
if (<condition>) <body> else <body>
for (i=0; i<100; i++)
j = i * 2
for (i=0, j=20; i<20; i++, j--) {
k = i * j
t_print(i, j, k)
}
while (k > 0)
{
k = k - 1
t_print(k)
}
for (;;) {
if (i-- < 1)
break
}
Macro Subroutines
Built in Variables
$cursor Position of the cursor in the current
window.
$column Column number of the cursor position in the
current window.
$em_tab_dist If tab emulation is turned on in the Tabs...
dialog of the Preferences menu, value is the
distance between emulated tab stops. If tab
emulation is turned off, value is -1.
$file_name Name of the file being edited in the current
window, stripped of directory component.
$file_path Directory component of file being edited in
the current window.
$language_mode Name of language mode set in the current
window.
$line Line number of the cursor position in the
current window.
$modified True if the file in the current window has
been modified and the modifications have not
yet been saved.
$selection_start, Beginning and ending positions of the
$selection_end primary selection in the current window, or
-1 if there is no text selected in the
current window.
$selection_left, Left and right character offsets of the
$selection_right rectangular (primary) selection in the
current window, or -1 if there is no
selection or it is not rectangular.
$tab_dist The distance between tab stops for a
hardware tab character, as set in the
Tabs... dialog of the Preferences menu.
$text_length The length of the text in the current window.
$use_tabs Whether the user is allowing the NEdit to
insert tab characters to maintain spacing in
tab emulation and rectangular dragging
operations. (The setting of the "Use tab
characters in padding and emulated tabs"
button in the Tabs... dialog of the
Preferences menu.)
$wrap_margin The right margin in the current window for
text wrapping and filling.
append_file( string, filename )
Appends a string to a named file. Returns 1 on successful write, or 0 if
unsuccessful.
beep()
Ring the bell.
clipboard_to_string()
Returns the contents of the clipboard as a macro string. Returns empty
string on error.
dialog( message, btn_1_label, btn_2_label, ... )
Pop up a dialog for querying and presenting information to the user. First
argument is a string to show in the message area of the dialog. Up to eight
additional optional arguments represent labels for buttons to appear along
the bottom of the dialog. Returns the number of the button pressed (the
first button is number 1), or 0 if the user closed the dialog via the window
close box.
focus_window( window_name )
Sets the window on which subsequent macro commands operate. window_name can
be either a fully qualified file name, or one of "last" for the last window
created, or "next" for the next window in the chain from the currently
focused window (the first window being the one returned from calling
focus_window("last"). Returns the name of the newly-focused window, or an
empty string if the requested window was not found.
get_character( position )
Returns the single character at the position
indicated by the first argument to the routine from the current window.
get_range( start, end )
Returns the text between a starting and ending position from the current
window.
get_selection()
Returns a string containing the text currently selected by the primary
selection either from the current window (no keyword), or from anywhere on
the screen (keyword "any").
getenv( name )
Gets the value of an environment variable.
length( string )
Returns the length of a string
list_dialog( message, text, btn_1_label, btn_2_label, ... )
Pop up a dialog for prompting the user to choose a line from the given text
string. The first argument is a message string to be used as a title for the
fixed text describing the list. The second string provides the list data:
this is a text string in which list entries are separated by newline
characters. Up to seven additional optional arguments represent labels for
buttons to appear along the bottom of the dialog. Returns the line of text
selected by the user as the function value (without any newline separator) or
the empty string if none was selected, and number of the button pressed (the
first button is number 1), in $list_dialog_button. If the user closes the
dialog via the window close box, the function returns the empty string, and
$list_dialog_button returns 0.
max( n1, n2, ... )
Returns the maximum value of all of its arguments
min( n1, n2, ... )
Returns the minimum value of all of its arguments
read_file( filename )
Reads the contents of a text file into a string. On success, returns 1 in
$read_status, and the contents of the file as a string in the subroutine
return value. On failure, returns the empty string "" and an 0 $read_status.
replace_in_string( string, search_for, replace_with, [type] )
Replaces all occurrences of a search string in a string with a replacement
string. Arguments are 1: string to search in, 2: string to search for, 3:
replacement string. Argument 4 is an optional search type, one of "literal",
"case" or "regex". The default search type is "literal". Returns a new
string with all of the replacements done, or an empty string ("") if no
occurrences were found.
replace_range( start, end, string )
Replaces all of the text in the current window between two positions.
replace_selection( string )
Replaces the primary-selection selected text in the current window.
replace_substring( string, start, end, replace_with )
Replacing a substring between two positions in a string within another string.
search( search_for, start, [search_type, wrap, direction] )
Searches silently in a window without dialogs, beeps, or changes to the
selection. Arguments are: 1: string to search for, 2: starting position.
Optional arguments may include the strings: "wrap" to make the search wrap
around the beginning or end of the string, "backward" or "forward" to change
the search direction ("forward" is the default), "literal", "case" or "regex"
to change the search type (default is "literal"). Returns the starting
position of the match, or -1 if nothing matched. also returns the ending
position of the match in search_end
search_string( string, search_for, start, [search_type, direction] )
Built-in macro subroutine for searching a string. Arguments are 1: string to
search in, 2: string to search for, 3: starting position. Optional arguments
may include the strings: "wrap" to make the search wrap around the beginning
or end of the string, "backward" or "forward" to change the search direction
("forward" is the default), "literal", "case" or "regex" to change the search
type (default is "literal"). Returns the starting position of the match, or
-1 if nothing matched. Also returns the ending position of the match in
$search_end.
select( start, end )
Selects (with the primary selection) text in the current buffer between a
starting and ending position.
select_rectangle( start, end, left, right )
Selects a rectangular area of text between a starting and ending position,
and confined horizontally to characters displayed between positions "left",
and "right".
set_cursor_pos( position )
Set the cursor position for the current window.
set_language_mode( mode )
Change language mode for the current window.
shell_command( command, input_string )
Executes a shell command, feeding it input from input_string. On completion,
output from the command is returned as the function value, and the command's
exit status is returned in the global variable $shell_cmd_status.
string_dialog( message, btn_1_label, btn_2_label, ... )
Pop up a dialog prompting the user to enter information. The first argument
is a string to show in the message area of the dialog. Up to nine additional
optional arguments represent labels for buttons to appear along the bottom of
the dialog. Returns the string entered by the user as the function value,
and number of the button pressed (the first button is number 1), in
$string_dialog_button. If the user closes the dialog via the window close
box, the function returns the empty string, and $string_dialog_button returns
0.
string_to_clipboard( string )
Copy the contents of a macro string to the clipboard.
substring( string, start, end )
Returns the portion of a string between a starting and ending position.
t_print( string1, string2, ... )
Writes strings to the terminal (stdout) from which NEdit was started.
tolower( string )
Return an all lower-case version of string.
toupper( string )
Return an all upper-case version of string.
write_file( string, filename )
Writes a string (parameter 1) to a file named in parameter 2. Returns 1 on
successful write, or 0 if unsuccessful.
Action Routines
All of the editing capabilities of NEdit are represented as a special type of
subroutine, called an action routine, which can be invoked from both macros
and translation table entries (see "Key Binding" in the
Customizing section of the Help menu).
File Menu Search Menu
--------------------- -----------------------
new() find()
open() find_dialog()
open_dialog() find_again()
open_selected() find_selection()
close() replace()
save() replace_dialog()
save_as() replace_all()
save_as_dialog() replace_in_selection()
revert_to_saved() replace_again()
include_file() goto_line_number()
include_file_dialog() goto_line_number_dialog()
load_tags_file() goto_selected()
load_tags_file_dialog() mark()
load_macro_file() mark_dialog()
load_macro_file_dialog() goto_mark()
print() goto_mark_dialog()
print_selection() goto_matching()
unload_tags_file() select_to_matching()
exit() find_definition()
split_window()
close_pane()
Edit Menu
--------------------- Shell Menu
undo() -----------------------
redo() filter_selection_dialog()
delete() filter_selection()
select_all() execute_command()
shift_left() execute_command_dialog()
shift_left_by_tab() execute_command_line()
shift_right() shell_menu_command()
shift_right_by_tab()
uppercase() Macro Menu
lowercase() -----------------------
fill_paragraph() macro_menu_command()
control_code_dialog() repeat_macro()
repeat_dialog()
execute_command( shell-command )
filter_selection( shell-command )
find( search_string [, search-direction], [search-type] )
find_again( [search-direction] )
find_definition( [tag-name] )
find_dialog( [search_direction] )
find_selection( [search-direction] )
goto_line_number( [line-number] )
goto_mark( mark-letter )
include( filename )
load_tags_file( filename )
macro_menu_command( macro-menu-item-name )
mark( mark-letter )
open( filename )
replace( search-string, replace-string,
[, search-direction] [, search-type] )
replace_again( [search-direction] )
replace_dialog( [search-direction] )
replace_in_selection( search-string,
replace-string [, search-type] )
save_as( filename )
shell_menu_command( shell-menu-item-name )
unload_tags_file( filename )
filename Path names are interpreted relative
to the directory from which NEdit was
started, wildcards and `~' are not
expanded.
search-direction Either "forward" or "backward"
search-type Either "literal", "case", or "regex"
mark-letter The mark command limits users to
single letters. Inside of macros,
numeric marks are allowed, which won't
interfere with marks set by the user.
(macro or shell) Name of the command exactly as
-menu-item-name specified in the Shell Menu or
Macro Menu dialogs
backward_character()
Moves the cursor one character to the left.
backward_paragraph()
Moves the cursor to the beginning of the paragraph, or
if the cursor is already at the beginning of a paragraph, moves the cursor to
the beginning of the previous paragraph. Paragraphs are defined as regions
of text delimited by one or more blank lines.
backward_word()
Moves the cursor to the beginning of a word, or, if the
cursor is already at the beginning of a word, moves the cursor to the
beginning of the previous word. Word delimiters are user-settable, and
defined by the X resource wordDelimiters.
beginning_of_file()
Moves the cursor to the beginning of the file.
beginning_of_line()
Moves the cursor to the beginning of the line.
beginning_of_selection()
Moves the cursor to the beginning of the selection
without disturbing the selection.
copy_clipboard()
Copies the current selection to the clipboard.
copy_primary()
Copies the primary selection to the cursor.
copy_to()
If a secondary selection exists, copies the secondary selection to
the cursor. If no secondary selection exists, copies the primary selection
to the pointer location.
copy_to_or_end_drag()
Completes either a secondary selection operation, or a
primary drag. If the user is dragging the mouse to adjust a secondary
selection, the selection is copied and either inserted at the cursor
location, or, if pending-delete is on and a primary selection exists in the
window, replaces the primary selection. If the user is dragging a block of
text (primary selection), completes the drag operation and leaves the text at
it's current location.
cut_clipboard()
Deletes the text in the primary selection and places it in
the clipboard.
cut_primary()
Copies the primary selection to the cursor and deletes it at
its original location.
delete_selection()
Deletes the contents of the primary selection.
delete_next_character()
If a primary selection exists, deletes its contents.
Otherwise, deletes the character following the cursor.
delete_previous_character()
If a primary selection exists, deletes its
contents. Otherwise, deletes the character before the cursor.
delete_next_word()
If a primary selection exists, deletes its contents.
Otherwise, deletes the word following the cursor.
delete_previous_word()
If a primary selection exists, deletes its contents.
Otherwise, deletes the word before the cursor.
delete_to_start_of_line()
If a primary selection exists, deletes its
contents. Otherwise, deletes the characters between the cursor and the start
of the line.
delete_to_end_of_line()
If a primary selection exists, deletes its contents.
Otherwise, deletes the characters between the cursor and the end of the line.
deselect_all()
De-selects the primary selection.
end_of_file()
Moves the cursor to the end of the file.
end_of_line()
Moves the cursor to the end of the line.
end_of_selection()
Moves the cursor to the end of the selection without
disturbing the selection.
exchange()
Exchange the primary and secondary selections.
extend_adjust()
Attached mouse-movement events to begin a selection between
the cursor and the mouse, or extend the primary selection to the mouse
position.
extend_end()
Completes a primary drag-selection operation.
extend_start()
Begins a selection between the cursor and the mouse. A
drag-selection operation can be started with either extend_start or
grab_focus.
forward_character()
Moves the cursor one character to the right.
forward_paragraph()
Moves the cursor to the beginning of the next paragraph.
Paragraphs are defined as regions of text delimited by one or more blank
lines.
forward_word()
Moves the cursor to the beginning of the next word. Word
delimiters are user-settable, and defined by the X resource wordDelimiters.
grab_focus()
Moves the cursor to the mouse pointer location, and prepares for
a possible drag-selection operation (bound to extend_adjust), or multi-click
operation (a further grab_focus action). If a second invocation of grab
focus follows immediately, it selects a whole word, or a third, a whole line.
insert_string("string")
If pending delete is on and the cursor is inside the
selection, replaces the selection with "string". Otherwise, inserts "string"
at the cursor location.
key_select("direction")
Moves the cursor one character in "direction"
("left", "right", "up", or "down") and extends the selection. Same as
forward/backward-character("extend"), or process-up/down("extend"), for
compatibility with previous versions.
move-destination()
Moves the cursor to the pointer location without
disturbing the selection. (This is an unusual way of working. We left it in
for compatibility with previous versions, but if you actually use this
capability, please send us some mail, otherwise it is likely to disappear in
the future.
move_to()
If a secondary selection exists, deletes the contents of the
secondary selection and inserts it at the cursor, or if pending-delete is on
and there is a primary selection, replaces the primary selection. If no
secondary selection exists, moves the primary selection to the pointer
location, deleting it from its original position.
move_to_or_end_drag()
Completes either a secondary selection operation, or a
primary drag. If the user is dragging the mouse to adjust a secondary
selection, the selection is deleted and either inserted at the cursor
location, or, if pending-delete is on and a primary selection exists in the
window, replaces the primary selection. If the user is dragging a block of
text (primary selection), completes the drag operation and deletes the text
from it's current location.
newline()
Inserts a newline character. If Auto Indent is on, lines up the
indentation of the cursor with the current line.
newline_and_indent()
Inserts a newline character and lines up the indentation
of the cursor with the current line, regardless of the setting of Auto
Indent.
newline_no_indent()
Inserts a newline character, without automatic
indentation, regardless of the setting of Auto Indent.
next_page()
Moves the cursor and scroll forward one page.
page_left()
Move the cursor and scroll left one page.
page_right()
Move the cursor and scroll right one page.
paste_clipboard()
Insert the contents of the clipboard at the cursor, or if
pending delete is on, replace the primary selection with the contents of the
clipboard.
previous_page()
Moves the cursor and scroll backward one page.
process_bdrag()
Same as secondary_or_drag_start for compatibility with previous versions.
process_cancel()
Cancels the current extend_adjust, secondary_adjust, or
secondary_or_drag_adjust in progress.
process_down()
Moves the cursor down one line.
process_return()
Same as newline for compatibility with previous versions.
process_shift_down()
Same as process_down("extend") for compatibility with previous versions.
process_shift_up()
Same as process_up("extend") for compatibility with previous versions.
process_tab()
If tab emulation is turned on, inserts an emulated tab,
otherwise inserts a tab character.
process_up()
Moves the cursor up one line.
scroll_down(nLines)
Scroll the display down (towards the end of the file) by nLines.
scroll_up(nLines)
Scroll the display up (towards the beginning of the file) by nLines.
scroll_to_line(lineNum)
Scroll to position line number lineNum at the top of
the pane. The first line of a file is line 1.
secondary_adjust()
Attached mouse-movement events to extend the secondary
selection to the mouse position.
secondary_or_drag_adjust()
Attached mouse-movement events to extend the
secondary selection, or reposition the primary text being dragged. Takes two
optional arguments, "copy", and "overlay". "copy" leaves a copy of the
dragged text at the site at which the drag began. "overlay" does the drag in
overlay mode, meaning the dragged text is laid on top of the existing text,
obscuring and ultimately deleting it when the drag is complete.
secondary_or_drag_start()
To be attached to a mouse down event. Begins drag
selecting a secondary selection, or dragging the contents of the primary
selection, depending on whether the mouse is pressed inside of an existing
primary selection.
secondary_start()
To be attached to a mouse down event. Begin drag selecting
a secondary selection.
select_all()
Select the entire file.
self_insert()
To be attached to a key-press event, inserts the character
equivalent of the key pressed.
Customizing NEdit
NEdit can be customized many different ways. The most important
user-settable options are presented in the Preferences menu, including all
options that users might need to change during an editing session. Options
set in the Default Settings sub-menu of the Preferences menu can be preserved
between sessions by selecting Save Defaults, which writes a file called
.nedit in the user's home directory. See the section titled "Preferences"
for more details.
Preferences
The Preferences menu allows you to set options for both the current editing
window, and default values for newly created windows and future NEdit
sessions. Options in the Preferences menu itself (not in the Default
Settings sub-menu) take effect immediately and refer to the current window
only. Options in the Default Settings sub-menu have no effect on the current
window, but instead provide initial settings for future windows created using
the New or Open commands. Preferences set in the Default Settings sub-menu
can also be saved in a file that is automatically read by NEdit at startup
time, by selecting Save Defaults.
Default Settings -- Menu of initial settings for
future windows. Generally the same as the
options in the main part of the menu, but apply
as defaults for future windows created during
this NEdit session. These settings can be saved
using the Save Defaults command below, to be
loaded automatically each time NEdit is started.
Save Defaults -- Save the default options as set
under Default Settings for future NEdit sessions.
Statistics Line -- Show the full file name, line
number, and length of the file being edited.
Incremental Search Line -- Keep the incremental search
bar (Search -> Find Incremental) permanently
displayed at the top of the window.
Show Line Numbers -- Display line numbers to the right
of the text.
Language Mode -- Tells NEdit what language (if any) to
assume, for selecting language-specific features
such as highlight patterns and smart indent macros,
and setting language specific preferences like word
delimiters, tab emulation, and auto-indent. See
Features for Programming -> Programming with NEdit
for more information.
Auto Indent -- Setting Auto Indent "on" maintains a
running indent (pressing the Return key will line
up the cursor with the indent level of the previous
line). If smart indent macros are available for
the current language mode, smart indent can be
selected and NEdit will attempt to guess proper
language indentation for each new line. See
Help -> Features for Programming -> Automatic
Indent for more information.
Wrap -- Choose between two styles of automatic wrapping
or none. Auto Newline wrap, wraps text at word
boundaries when the cursor reaches the right margin,
by replacing the space or tab at the last word
boundary with a newline character. Continuous Wrap
wraps long lines which extend past the right margin.
Continuous Wrap mode is typically used to produce
files where newlines are ommitted within paragraphs,
to make text filling automatic (a kind of poor-man's
word processor). Text of this style is common on
Macs and PCs but is not necessarily supported very
well under Unix (except in programs which deal with
e-mail, for which it is often the format of choice).
Wrap Margin -- Set margin for Auto Newline Wrap,
Continuous Wrap, and Fill Paragraph. Lines may,
be wrapped at the right margin of the window, or
the margin can be set at a specific column.
Tabs -- Set the tab distance (number of characters
between tab stops) for tab characters, and
control tab emulation and use of tab characters
in padding and emulated tabs.
Text Font... -- Change the font(s) used to display
text (fonts for menus and dialogs must be set
using X resources for the text area of the window).
See below for more information.
Highlight Syntax -- If NEdit recognizes the language
being edited, and highlighting patterns are
available for that language, use fonts and colors
to enhance viewing of the file. (See Help ->
Features for Programming -> Syntax Highlighting
for more information.
Make Backup Copy -- On Save, write a backup copy of
the file as it existed before the Save command
with the extension .bck (Unix only).
Incremental Backup -- Periodically make a backup copy
of the file being edited under the name `~filename`
on Unix or `_filename` on VMS (see Crash Recovery).
Show Matching (..) -- Momentarily highlight matching
parenthesis, brackets, and braces when one of
these characters is typed, or when the insertion
cursor is positioned after it.
Overtype -- In overtype mode, new characters entered
replace the characters in front of the insertion
cursor, rather than being inserted before them.
Read Only -- Lock the file against accidental
modification. This temporarily prevents the
file from being modified in this NEdit session.
Note that this is diferent from setting the file
protection.
Language Modes -- Define language recognition
information (for determining language mode from
file name or content) and set language specific
preferences.
Tag Collisions -- How to react to multiple tags for
the same name. Tags are described in the section:
Features for Programmers -> Finding Declarations
(ctags). In Show All mode, all matching tags are
displayed in a dialog. In Smart mode, if one of
the matching tags is in the current window, that
tag is chosen, without displaying the dialog.
Customize Menus -- Add/remove items from the Shell,
Macro, and window background menus (see below).
Searching -- Options for controlling the behavior of
Find and Replace commands:
Verbose - Presents search results in dialog
form, asks before wrapping a search back
around the beginning (or end) of the file.
Keep Dialogs Up - Don't pop down Replace and
Find boxes after searching.
Default Search Style - Initial setting for
search type in Find and Replace dialogs.
Syntax Highlighting -- Program and configure enhanced
text display for new or supported languages (See
Features for Programming -> Syntax Highlighting).
Sort Open Prev. Menu -- Option to order the File ->
Open Previous menu alphabetically, versus in order
of last access.
Popups Under Pointer -- Display pop-up dialogs
centered on the current mouse position, as opposed
to centered on the parent window. This generally
speeds interaction, and is essential for users who
users who set their window managers so keyboard
focus follows the mouse.
Modification Warnings -- Pop up a warning dialog when
files get changed external to nedit.
Exit Warnings -- Ask before exiting when two or more
files are open in an nedit session.
Initial Window Size -- Default size for new windows.
+---++---++---+
|a >||b >||c |
+---++---+|d |
+---+
Make C Prototypes@C@C++
Make Class Template@C++
Make Prototypes@C@C++
Make Prototypes@Java
Make Prototypes@*
Make Prototypes
nedit -import <file>
nedit.highlightPatterns:\
My Language:1:0{\n\
Comment:"#":"$"::Comment::\n\
Loop Header:"^[ \\t]*loop:":::Loop::\n\
}
nedit.languageModes: My Language:.my::::::
nedit.styles: Loop:blue:Bold
X Resources
NEdit ha