Contact Contact Us
Contact Us

Intro to Linux Command Line Text Editors

What command line editors are there?

On the HPC, there are a wide variety of text editors that you can use. The most straightforward one is, nano which you can access by typing nano file_name. Next you have VI/VIM, which you can access by typing either, vi file_name or vim file_name on the command line. Next, there is emacs, which can be accessed by typing emacs . Now emacs is the most complicated but is also the most flexible. If you're interested in emacs, we recommend you look at the documentation yourself at, https://www.gnu.org/software/emacs/manual/html_node/emacs/index.html. There are many more editors, however, these are among the most popular and is confirmed to be on the hpc.

Intro to Nano

Nano is really easy to use. After you start nano, you can make whatever edits you want by simply typing. Afterwards, you can exit and save with "Ctrl-X". You can cut a line of text with "Ctrl-K" and paste it with "Ctrl-U". You can copy with "Alt-6".

You can search with "Ctrl-W", then type the word you want to find. To find and replace press "Ctrl-\" You can also undo your last action with "Alt-U" and redo with "Alt-R".

You can navigate with the arrow keys. You can also specify a file to write out to by "Ctrl-O".

You can find more info on nano at https://www.nano-editor.org/docs.php. You can get additional help with "Ctrl-G".

Intro to Vi/Vim

Vim operations on the concept of modes. You will spend most of your time in either insert mode, or normal mode. You start in normal mode and can enter insert mode by typing 'i'. While in this mode, whatever you type is typed into the file. To get back to normal mode press the 'ESC' key. From here, you can save your changes with ':w'. You can exit with ':q'. You can exit and save with ':wq'.

You can enter visual mode by pressing 'v' (for selecting individual characters), and 'V' (for selecting entire lines). You can copy the text you selected by pressing 'y', and to cut the text press 'x'. Next you can paste the text by pressing 'p' while in normal mode.

You can also jump to a specific line by typing ':(number)'. You can also navigate your cursor left by 'h', right by 'l', up by 'k' and down by 'j'. You can move to the end of the current word with 'e' and the start of the next word with 'w'. You can also move to the beginning of the previous word with 'b'. Next, you can also type a number before any of these movement options to repeat it n number of times.

You can search the file you're working on with '/(word)' for a foward search and to search with a backward search use '?(word'.

There is a tutorial you can follow for more help by typing in the command vimtutor. You can also find additional documentation at, https://vimguide.readthedocs.io/en/latest/vim.html

Using vscode

Finally, if you load the module vscode with module load vscode. Then you can just type vscode and it should open up.
PS: Remember when logging in to include the -X so you can have the xforwarding interface otherwise it won't work.