1. Server Mode and nc

Server Mode and nc

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 nc program when no servers are available.

The nc (for NEdit Client) program, which is distributed along with nedit, sends commands to an nedit server to open files, select lines, or execute editor actions. It accepts a limited set of the nedit command line options: -read, -create, -line (or +n), -do, and a list of file names. Listing a file on the nc command line means, open it if it is not already open and bring the window to the front. -read and -create affect only newly opened files, but -line and -do can also be used on files which are already open (See "NEdit Command Line" for more information).

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 execute).

nc also accepts one command line option of its own, -noask (or -ask), which instructs it whether to automatically start a server if one is not available. This is also settable via the X resource, nc.autoStart (See X Resources).

Sometimes it is useful to have more than one NEdit server running, for example to keep mail and programming work separate, or more importantly for working with tools like ClearCase which provide different views of the file system from different shells. The option, -svrname, to both nedit and nc, allow you to start, and communicate with, separate named servers. A named server responds only to requests with the corresponding -svrname argument.

Communication between nc and nedit is through the X display. So as long as X windows is set up and working properly, nc will 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".


Send questions and comments to: nedit_support@fnal.gov.