Editing Text with
While there are options like VS Code that are closer to the types of text editors used on a normal desktop computer, they can be difficult to setup on the HPCC, and if you're just moving around using the command line, you might want to quickly drop in and edit a file without having to switch programs.
We recommend that new users try
nano to edit files on the command line. While
there are other text editors you can use directly from the shell (e.g.,
nano is much more user-friendly, and easier to start with.
Opening a file
To open a file using
into the shell, replacing
<filename> with the file you'd like to edit. You
can either give the full path to the file like
or if you're already in the directory where your file is, you can just use the filename, like
If the file doesn't exist,
nano will create it for you.
Editing a file
Once the file is open, you can use the arrow keys, page up/down, and home/end to move around. You can type anywhere to add text.
Copying and pasting
To copy, first use the mouse to highlight text. Right click, and choose Copy from the menu.
To paste, move the cursor to the position you want to paste using the arrow keys. Right click, and choose Paste from the menu.
The keyboard shortcuts to copy and paste depend on your operating system and terminal program:
|Text selected with the mouse will be copied by default
shift + insert
cmd + c
cmd + v
This depends on your terminal, but usually the following work:
ctrl + shift + c
ctrl + shift + v
If you need to scroll through a file to select all of the text you need to
copy, the shortcuts in
nano become more complicated. A simpler way to do this
is to exit
nano, and enter
on the command line.
This will output all contents of the filename you give to your command line, and you can select the part you want to copy with the mouse. The copy and paste shortcuts above will work in the same way.
At the bottom of the screen, you will see some helpful key combinations:
Each of these combinations starts with
^ symbolizing the
ctrl key on your
keyboard. For example, to exit, hold
ctrl on your keyboard and press
nano shows an upper case
X, you don't need to use the
The shortcut descriptions are meant to be mnemonic and match the key used, which can lead to some confusion. Some helpful shortcuts in plain language include:
|Save a file
|Search for text
|Delete a line
|Paste line that was deleted
Saving a file
To save a file, use
^O (that is, hold the
ctrl key and press
o). You will
be asked what filename to save your file to, with the default being the already
existing filename. Press the
return key without making any changes
to the filename to save.
If you'd like to make a copy or save your edits in a new place, change the filename before accepting.
To exit, use
^X (that is, hold the
ctrl key and press
x). If you exit
before having saved the file,
nano will ask if you would like to save before
exiting. Press the
y key to save changes, the
n to discard your changes, or
^C to cancel.