Editor
For anything longer than a line or two, use the Editor. It has syntax highlighting, line numbers, tabs, and .R files you can save.
Writing R Scripts
Write a script, then run all of it or just a selection.




Parts of the screen
- The tab bar shows your open files. Tap + for a new tab
- Line numbers sit in the left gutter
- Syntax highlighting colors keywords, strings, functions and comments differently
- The output panel at the bottom shows results when you run your script
- The toolbar holds undo, redo, find, the editor actions menu and the run button
Syntax Highlighting
Code is colored as you type:
- Keywords like
if,for,function,return, shown in purple - Functions like
print(),mean(),ggplot(), shown in blue - Strings like
"hello world", shown in red/coral - Numbers like
42,3.14, shown in green - Comments starting with
#, shown in gray




Colors follow light and dark mode, and keep up even in scripts thousands of lines long.
Editor Themes
Nine built-in themes color the whole app as well as your code. Here are Dracula, Monokai, Solarized Light and Nord. Solarized Light is a light theme and the other three are dark, so each is shown in the appearance it belongs to.
















Pick one theme for light mode and one for dark in Settings > Appearance, where you can also create, import and export your own.
Running Your Code
The play button’s color says what it will run.
- Green means nothing is selected, so it runs the whole script.
- Blue means it runs only the selected text. Long-press and drag to select.
1 2
1 2
1 2
1 2
- The green play button runs the entire script
- The output panel shows results after a run
With a selection, the button turns blue.
1 2
1 2
1 2
1 2
- The blue play button runs only the selection
- The selected text is the highlighted code that will run
Output appears in the Output panel at the bottom. Drag its handle to resize it, tap the chevron to collapse it, or double-tap the divider to toggle it.
To find where a script goes wrong, run it a section at a time.
Running one statement at a time
With a keyboard, Cmd+Return runs the selection or, with nothing selected, the whole statement on the cursor’s line. On the first line of a call written over several lines, it runs the whole call. Inside a loop or function body it runs that line’s statement, so you can step through the body. On the line with the for, the function or a brace, it runs the whole block. A comment line runs by itself, and a blank line runs nothing.
The cursor then moves to the next statement, past blanks and comments, so pressing Cmd+Return again walks the script a statement at a time. A selection stays selected. While R is busy it runs nothing and the cursor stays put. On iPad it is also Run > Run Line or Selection in the menu bar.
A plot() and the abline(), legend() or grid() after it are separate statements. Run one at a time, the second reports “plot.new has not been called yet”. Select them together, or use Run All.
Running a whole script
A run sends the script, or the selection, to R as one piece, as source() would, and R prints every visible result in order. So:
- A plot and the calls that add to it, such as
abline(),legend()orpar(mfrow = ...), draw on one plot, blank lines or not. - The run stops at the first error, and a syntax error points at the line you wrote.
- In the iPad 4-Pane Workspace, the script is echoed in the Console pane as one block and logged in History as one entry. Anything half-typed in the Console stays.
Scripts with Windows (CRLF) line endings run as they are, and the file keeps its line endings.
Stopping a run
While R runs, the Run button becomes Stop. Tap it, or press Cmd+., and R stops where it is, variables kept. A long run, or a step that can’t be interrupted at once, brings the Console’s banner between the script and its output, with Restart R. Long means over a minute, unless you change it in Settings > R Session > Suggest Stopping After.
Example scripts
Examples, in the document icon’s menu, opens one of three built-in scripts (Getting Started, Data Analysis, Plotting) as an unsaved copy. At the default text size their lines don’t wrap on any iPhone, and Cmd+Return steps through them.




The R Keyboard Toolbar
The Editor has the Console’s toolbar of R operators above the keyboard, so <-, |>, brackets and the rest are one tap away.
1 2
1 2
1 2
1 2
- The R operator buttons are a scrollable row of
<-,|>,(),[],{},"",~,c(),::,$,@,%in%,!,&,|,# - Dismiss keyboard hides the keyboard so you can see more of your code
Tabs and File Management
Open files sit in tabs along the top.
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
- The tab bar shows all open files. Tap a tab to switch to it
- A blue dot marks a tab with unsaved changes
- The close button, the x on a tab, closes it
- The new tab button, +, opens a fresh editor tab
The document icon at the top left opens the File menu:
- New Tab creates a fresh, empty editor tab
- Open… opens the iOS file picker, to load any
.Ror text file from Files, iCloud Drive or another storage provider - Open Recent reopens a recent file
- Save saves the current tab, asking for a filename if the file is new
- Examples opens one of the built-in example scripts as an unsaved copy
- Export to Gist shares your code as a GitHub Gist
Scripts are saved as .R files in the current project and appear in Files.
Saving safely
Open tabs are saved a moment after each change and whenever you leave the Editor or the app, so restarting R or a relaunch never loses your typing. Tabs, split view, the output panel and Undo survive a trip to another screen.
Before Save writes over a file, the Editor checks whether something else, such as an iPad editor window or another app, changed it. If so, choose Overwrite or Keep Both, which saves yours beside it as, say, analysis 2.R. A tab you haven’t edited picks up the newer file.
Files keep their text encoding. A Windows-1252 script opens correctly and saves back the same way. Type a character the encoding can’t hold and the Editor offers to save as UTF-8.
Rename or move a file in Files or Projects and its tab follows, so Save writes to the new name. A tab whose file was deleted keeps its text and asks where to save it.
Code Snippets
Snippets, in the … menu, holds templates for common R patterns, grouped by category, such as data frames, plotting, models and functions.
















- Top left. The … menu lists Snippets with the other editor actions.
- Top right. The snippet categories, including Data Structures, Visualization and Statistics.
- Bottom left. The Data Structures category, with templates for vectors, matrices and data frames.
- Bottom right. A Data Frame snippet inserted into the editor and run, with its output.
Snippets have placeholders for your own names and values, and you can add snippets of your own.
Snippets double as worked examples. Insert one, read through it, and modify it to see what changes.
Code Completion
As you type, the Editor suggests functions, variables and package members in a list below the cursor, or above it when there is more room there. It shows up to six rows before it scrolls. Tap one to insert it. Undo takes it back out. Typing ( after a function name shows its parameters (signature help), and Ctrl+Space asks for suggestions at the cursor.
The list narrows as you type, as in the Console. It keeps narrowing through the first letter after $, ::, ( or a comma, and through the digits of a name such as log1p. A token that starts with a digit gets no list, and R’s ... is never offered. Left alone, the list closes after three seconds, but not under VoiceOver or Switch Control.
With a hardware keyboard, while the list is open:
- Up and Down move a highlight
- Tab inserts the highlighted row, or the first if you haven’t moved the highlight
- Return inserts the highlighted row once you have moved the highlight, and otherwise starts a new line
- Escape closes the list
The list grows with the editor font. VoiceOver announces how many completions there are and reads each row as, for example, “mean, function”.




Find and Replace
The magnifying glass, or Cmd+F, opens the system Find bar in the pane you are working in. Matches are highlighted, the arrows step through them, and Replace changes one or all. Replacements can be undone.
1 2 3
1 2 3
1 2 3
1 2 3
- The search field takes a term and finds every match in your code
- The match counter shows how many matches there are and which one is selected
- Replace reveals the replace field
Code Folding
Turn on folding in the … menu to collapse functions, loops and other blocks.
1 2
1 2
1 2
1 2
- The fold chevron, the arrow in the gutter, collapses or expands a code block
- A folded region hides its code behind a summary indicator
Tapping a fold’s line number works too. A fold stays with its function when lines change above it. Fold All and Unfold All are under Code Folding in the … menu, and folding works in both panes of the split editor.
Split Editor
With two or more tabs open, Split Editor in the … menu shows two files side by side.
1 2 3
1 2 3
1 2 3
1 2 3
- The left pane shows one file, the primary tab
- The right pane shows a second file beside it
- The split divider drags to resize the panes
The panes always show different tabs. Picking the right pane’s tab on the left swaps them. Save, Close, Run, the … menu and shortcuts act on the pane you last typed or tapped in. Choosing a tab from the tab bar, or opening or closing the split, makes the left pane current. Jump to Line, Code Outline and Export to Gist act on whichever pane was current when you opened them.
Drag the divider anywhere between a quarter and three quarters of the width. VoiceOver adjusts it as “Left and right editor divider”. The output panel’s handle works the same way.
iPad windows
Each iPad window has its own editor, tabs and autosave, so two windows never overwrite each other. A new window starts with an empty Untitled tab. Open in New Window in Files opens one file in its own editor window, which saves with Cmd+S and asks before closing with unsaved changes.
More Editor Features
Code Outline
The outline lists every function and section heading. Tap one to jump there.




Search Across Files
Search in Files (File menu > Navigate, or Cmd+Option+F when the editor text isn’t focused) searches every .R and .Rmd file in Documents.
The options are Match Case and Regex. Tap a result to open the file at that line.




Export to a GitHub Gist
Publishes the current file as a gist and gives you the link. It needs a GitHub token, which is kept in the Keychain.



