# Text Editors

## Text Viewing

Here are a few commands that are used to just display the text within a file:

more <FILENAME>     # Views text, use space bar to browse, 'q' to quit
less <FILENAME>     # Also views text, uses arrow keys to browse, 'q' to quit
cat  <FILENAME>     # Concatenates files and prints content to screen


## Text Editors

• Nano
• A simple terminal-based editor.
• Neovim
• Non-graphical (terminal-based) editor. Neovim is an improved version of vim.
• Vim Gvim
• Non-graphical (vim) or window-based editor (gvim). Vim is the improved version of vi.
• Emacs
• Non-graphical or window-based editor.
• Atom
• Window-based editor that runs on your local machine.
• Visual Studio Code
• Graphical editor that runs on your local machine that supports different plugins.

## Nano

The nano editor is the simplest to use and can be good for beginners:

nano <FILENAME>     # Open file if it exists, or create it


Navigation in nano uses the arrow keys, and all other commands are noted at the bottom of the screen. The CTRL key is used in combination with other keys to execute commands in nano.

For example, at the bottom of the nano screen it is noted that ^X is used to exit. This means you will need to hold the CTRL key and then press x in order to quit. After that, just follow the on screen prompts at the bottom.

For more nano commands, please visit Overview of nano shortcuts.

## Neovim / Vim / GVim / VI

All of these editors follow the same principals.

nvim <FILENAME>     # Open file if it exists, or create it
vim <FILENAME>      # Open file if it exists, or create it
gvim <FILENAME>     # Open file if it exists, or create it (must have XForwarding or VNC)
vi <FILENAME>       # Open file if it exists, or create it


## Emacs

Navigation in emacs also uses the arrow keys. It is similar to nano, in that, CTRL is combined with other keys to execute commands.

For example, to open a file, simply run the command with a file name:

emacs <FILENAME>     # Open file if it exists, or create it


Then, after you have made some changes, exit by holding the CTRL key and then pressing c, releasing and then holding the CTRL key once more and pressing c again. After that, just follow the on screen prompts at the bottom.

For more commands in emacs please visit GNU Emacs Reference Card

## Atom

### Remote Atom

After you have atom installed, you need to install the Remote Atom plugin. Click on edit, then preferences, then look for the install item on the left side menu. You should then be able to type remote-atom in the search field, find it and install it. After installation, atom should restart.

### Start Server

Once you have remote-atom installed, click Packages in the top menu, then Remote Atom, and then click Start Server. Atom may need to be restarted in order for you to see these new menu items.

### Cluster

SSH into cluster using a socket (replace <USERNAME> with your real username on the cluster):

ssh -R /rhome/<USERNAME>/.rmate.socket:localhost:52698 cluster.hpcc.ucr.edu


Note: Do not use a remote PORT, you must use a SOCKET FILE as shown above. There are security issues otherwise.

After you have logged into the cluster load rmate (alias is optional):

module load rmate
alias ratom=rmate


You can add this into your ~/.bashrc for convenience.

Then you should be able to open a file on the cluster and have it appear on your local machine:

rmate <FILENAME>


Once you have finished all your editing and close atom, be sure to delete the socket file from the cluster:

rm -f /rhome/<USERNAME>/.rmate.socket'


For more information regarding remote-atom, please visit Remote-Atom.

## Visual Studio Code

### Remote Editing

To setup Visual Studio Code to remotely edit files on the cluster, please go to slides 13 on this guide

## RStudio Server

Two options exist to access the RStudio Server IDE:

While the Shared Web Instance is easier for less experienced users, it does not allow to load a specific R version nor access more extensive computing resources. Thus, experienced users may prefer the Compute Node Instance as it does not share these limitations.

### 1. Shared Web Instance

R users can log in to their HPCC accounts via an RStudio Server instance. To do so, visit the HPCC RStudio Server. Next provide your HPCC login credentials and click the Sign In button.

### 2. Compute Node Instance

#### a. Interactive

Alternatively, an RStudio Server instances can be started directly on a compute node and accessed via an SSH tunnel. This involves the following steps.

1. SSH into the cluster as outlined here.

2. Log in to a compute node interactively via srun, where the proper parameters need to be specified by the user. These include partition name, RAM, number of CPU cores, wall time limit, etc. Additional details on using srun are available here.

srun --partition=short --mem=8gb --cpus-per-task=2 --ntasks=1 --time=2:00:00 --pty bash -l

1. Load the latest versions of R and RStudio Server using the module system:
module unload R

start-rserver.sh

1. Next follow the instructions printed to the terminal after running start-rserver.sh. The command-lines given in these instructions need be executed in a terminal of a user’s local system, and not on the remote system where start-rserver.sh was exectuted.
The steps for launching an interactive job can be integrated into a script and submitted non-interactvely for a quicker deployment of a RStudio Server instance on a compute node. Instructions outling how to do this are located here.