Client/Server Mode

NEdit can be operated on its own, or as a two-part client/server application. Client/server mode is useful for integrating NEdit with software development environments, mailers, and other programs; or just as a quick way to open files from the shell command line without starting a new NEdit session.

To run NEdit in server mode, type:

      nedit -server

NEdit can also be started in server mode via the NEdit Client program (nc) when no servers are available.

The nc program, which is distributed along with NEdit, sends commands to an NEdit server to open files or execute editor actions. It can also be used on files that are already opened.

Listing a file on the nc command line means: Open it if it is not already open and bring the window to the front.

nc supports the following command line options:

    nc [-read] [-create]
       [-line n | +n] [-do command] [-lm languagemode]
       [-svrname name] [-svrcmd command]
       [-ask] [-noask] [-timeout seconds]
       [-geometry geometry | -g geometry] [-icon | -iconic]
       [-tabbed] [-untabbed] [-group] [-wait]
       [-V | -version]
       [-xrm resourcestring] [-display [host]:server[.screen]]
       [--] [file...]

-read
Open the file read-only regardless of its actual permissions. There is no effect if the file is already open.

-create
Don't warn about file creation when a file doesn't exist.

-line n, +n
Go to line number n. This will also affect files which are already open.

-do command
Execute an NEdit macro or action on the file following the -do argument on the command line.

If you use this command without a filename, nc would randomly choose one window to focus and execute the macro in.

-ask, -noask
Instructs nc to automatically start a server if one is not available. This overrides the X resource `nc.autoStart' (see X Resources).

-svrname name
Explicitly instructs nc which server to connect to, an instance of nedit(1) with a corresponding -svrname argument. By naming servers, you can run several simultaneously, and direct files and commands specifically to any one.

-svrcmd command
The command which nc uses to start an NEdit server. It is also settable via the X resource `nc.serverCommand' (see X Resources). Defaults to "nedit -server".

-lm languagemode
Initial language mode used.

-geometry geometry, -g geometry
The initial size and/or location of editor windows. See NEdit Command Line for details.

-icon, -iconic
Initial window state.

-display [<host>]:<server>[.<screen>]
The name of the X server to use. See NEdit Command Line for details.

-timeout seconds
Basic time-out period used in communication with an NEdit server. The default is 10 seconds. Also settable via the X resource `nc.timeOut'.

Under rare conditions (such as a slow connection), it may be necessary to increase the time-out period. In most cases, the default is fine.

-tabbed
Open all subsequent files in new tabs. Resets -group option.

-untabbed
Open all subsequent files in new windows. Resets -group option.

-group
Open all subsequent files as tabs in a new window.

-wait
Instructs nc not to return to the shell until all files given are closed.

Normally, nc returns once the files given in its command line are opened by the server. When this option is given, nc returns only after the last file given in this call is closed.

Note that this option affects all files in the command line, not only the ones following this option.

Note that nc will wait for all files given in the command line, even if the files were already opened.

Command Line Arguments

In typical Unix style, arguments affect the files which follow them on the command line, for example:

      incorrect:   nc file.c -line 25
      correct:     nc -line 25 file.c

-read, -create, and -line affect all of the files which follow them on the command line.

The -do macro is executed only once, on the next file on the line. -do without a file following it on the command line, executes the macro on the first available window (presumably when you give a -do command without a corresponding file or window, you intend it to do something independent of the window in which it happens to execute).

The -wait option affects all files named in the command line.

Multiple Servers

Sometimes it is useful to have more than one NEdit server running, for example to keep mail and programming work separate. The option, -svrname, to both nedit and nc, allows you to start, and communicate with, separate named servers. A named server responds only to requests with the corresponding -svrname argument. If you use ClearCase and are within a ClearCase view, the server name will default to the name of the view (based on the value of the CLEARCASE_ROOT environment variable).

Communication

Communication between nc and nedit is done through the X display. So as long as the X Window System is set up and working properly, nc will work properly as well. nc uses the DISPLAY environment variable, the machine name and your user name to find the appropriate server, meaning, if you have several machines sharing a common file system, nc will not be able to find a server that is running on a machine with a different host name, even though it may be perfectly appropriate for editing a given file.

The command which nc uses to start an nedit server is settable via the X resource nc.serverCommand, by default, "nedit -server".