Frame Editor

This guide explains how to work with the frame editor for editing source code, LaTeX documents, Command-line terminal etc. The screenshot below shows a Python file and a Terminal. In order to get that view, the frame editor is split vertically first, and then the right frame is split horizontally. After that, the bottom right frame is changed to a Terminal.

You can not only view the same Python source code in two places, but you can also work with e.g. IPython on the command-line in the same directory.

split screen with two views of source file plus terminal running ipython

Supported file types

Markdown

If you open/create a file ending with *.md, you’re presented by default with a split view of Markdown code on the left and HTML rendered output on the right hand side.

There’s an entire page in this guide dedicated to Markdown.

Text, Source Code, and Data Files

The frame editor lets you edit many types of text files. Here are some of the most common types, followed by the filename extension:

  • plain text: .txt

  • Python code: .py

  • Sage code: *.sage

  • C source code: *.c

  • C++ source code: *.c++

  • Java source code: *.java

  • Comma-separated data: *.csv

  • YAML data: *.yaml

  • JSON data: .json

HTML

Open/create a *.html file and you’ll see the rendered output on the right hand side. You can switch the rendered view between “Preview” (which is faster) or “iframe” (which renderes the page as it is) depending on your needs. You can even close the editor pane, to just see the rendered HTML.

R Markdown

Open a *.Rmd or *.rmd file to work with R Markdown. Depending on the configuration in the preamble, you either produce an HTML or PDF output. Do not forget to switch the panel for the rendered output accordingly. Here is an example of R markdown producing a pdf file:

example of R markdown producing a pdf file

If you produce PDF and HTML output, you can see both after splitting the panel.

There is a brief tutorial on R Markdown in the Project Library. To view the sample files, do the following:

  1. Open a project where you want the copied files to be placed.

  2. Open the Files tab.

  3. Click “Library” at upper right.

  4. Select “RMarkdown in CoCalc”.

  5. Click “Get a copy”.

fetching R Markdown intro from the project library

Multiple Cursors

You can get multiple cursors while editing any file in the frame editor using the mouse and ctrl+click (cmd+click on Mac).

If you switch to Sublime keybindings in “Account” > “Preferences” > “Editor settings”, you can select text and then use ctrl-D (cmd-D on Mac) to multi-select the next occurrence of the same text.

The frame editor also supports simultaneous editing by more than one user. In this case, separate cursors are displayed for each user.

Spell Checker

Here are two ways to spell-check your documents in CoCalc.

Use your browser’s native spell checker.

The CoCalc frame editor supports the browser’s native spell checker for varying file types, including .md, .rmd, and .html. See the documentation for your specific browser for information on how to enable and configure spell checking. You may have to save your file before the spell checker is activated.

Use the ``aspell`` Linux command.

The aspell utility will find possible misspellings and offer corrections. Here’s how to use it:

  1. Open a Linux Terminal

  2. aspell -t -c <filename.tex>

You can add words for aspell to ignore using personal dictionaries. These words won’t be underlined red. To do this create the file ~/.aspell.lang.pws, where lang is the choice of langauge. The first line of this file should be personal_ws-1.1 lang 0, where lang is the choice of language. Then add one word per line for aspell to ignore. For example, to ignore the words ‘bijection’ and ‘surjection’ in an English document, create the file ~/.aspell.en.pws with the content:

personal_ws-1.1 en 0
bijection
surjection

The changes will take place the next time aspell is run on the document.

Side Chat

You can share comments on a CoCalc file using a side chat panel. For more information, see Side Chat.

Search Inside the File

You can search for a string of text in your file while editing by hitting Ctrl-F (or Cmd-F on a Mac) and entering the string you want to search for in the blank that appears at the top. If you want to search for a regular expression rather than simple text, surround the regular expression with slashes. For example, to search for a pound sign and a space at the start of a line, enter /^# / for the search string.

search for string inside file being edited

search in a .sage file; regular expression hint is outlined

Implementation note: CoCalc’s frame editor search is implemented using the Codemirror search function.