1. Overview
  2. Editing commands
  3. Main menu

Overview

MobileCode is a code editor designed for mobile phones. It edits files locally on the device.

Many commands are inspired by vim. MobileCode, however, is always in "insert mode". You enact commands by tapping a menu button rather than entering "normal mode". For example, to delete a line in vim, you would type ESC-d-d. In MobileCode, you tap the menu button, then tap "Cut line".

The menu button is a floating transparent button. You can move it by dragging it.

In supported languages, files are rendered as nested "blocks". This can be disabled by "Disable blocks". Blocks are similar to code folding. They are divided by blank lines with balanced {}, recursively. A typical C file might appear as a block labeled "#include <...>", then a block for each section of global variables, and then a block for each function. A block's "label" is determined heuristically: if it looks like a function, it is the function name; if it starts with a comment, it is the comment; otherwise, it is the first nonblank line. Tap them to expand. When searching, results which match block labels appear first.

When lines are too long, their right edge is yellow. Tapping this will wrap the line.

In supported languages, when tapping the edge of an overlong line, the line is "expanded": a pretty-printed view of the line is shown, and modifications to the view format the view into a single line and overwrite the underlying line. These changes happen as you type; you do not need to close the expansion for changes to be "synced".

If expansions are not supported for the language, or if "Flow line" is tapped instead, the line will wrap around the edges of the screen.

Editing commands

Cut line

Deletes and copies the line the cursor is on. See Copy (Select) for the commands that appear after. (vim: dd)

Disable blocks

Disables blocks. The file is shown as most editors would typically show it. Blocks will not be used again, even on supported files, until Enable blocks is pressed.

Enable blocks

Shows the file as a series of nested blocks. Supported files will automatically use blocks when opened.

Enter below

Inserts a line below the current one and moves the cursor to its start. Indentation is copied. (vim: o)

Find

Looks for the regex in the text. As matches are navigated, the screen scrolls to each one (unlike search). (vim: /)

Done (Find)

Hides the find overlay.

First (Find)

Navigates to the first match in the text.

Next (Find)

Navigates to the next match in the text, wrapping. If no match is selected, it selects the first one relative to the screen.

Prev (Find)

Navigates to the previous match in the text, wrapping. If no match is selected, it selects the first one before the screen.

Flow line

Wraps the line around the edges of the screen.

Global replace

The first input buffer is a regex. Matches are searched from the start of the file. At each match, there is an option to replace the match with the second input buffer. <Enter> moves the cursor between the two buffers. (vim: :%s//gc)

Done (Global replace)

Stops matching and returns to where the screen was before.

Replace (Global replace)

Replaces the selected match with the second buffer.

Skip (Global replace)

Moves to the next match.

Go top

Scrolls to the top of the file.

Intent Termux

Android only. Asks Termux to run $PREFIX/usr/bin/mobilecodecmd. Specifically, sends a RUN_COMMAND intent to Termux with RUN_COMMAND_PATH set to /data/data/com.termux/files/usr/bin/mobilecodecmd. For this to work, you must add 'allow-external-apps = true' to ~/.termux/termux.properties, and create the command.

Join

Deletes the newline preceding the next line and replaces any indentation it had with a single space. (vim: J)

Paste

Pastes the system clipboard contents at the cursor.

Paste below

Pastes the system clipboard contents at the start of the next line and adjusts its indentation. (vim: preceded by Cut line, it is like d-d-p)

Save

Writes the file to its location. Note that expanded lines are merely views of their underlying line; whether they are expanded or not has no effect on how they are saved (always as a single line).

Save as

Opens a file picker, then updates the file's save location and saves it there.

Select

Starts selecting from the cursor's location. Wherever you tap, the selection will be updated to be between the tapped location and the location the cursor was when you originally tapped Select. Pressing backspace will cut the selection (copy and delete). (vim: v)

Cancel (Select)

Stops selecting.

Copy (Select)

Copies the selection to the system keyboard.

Include pre lines (Select)

Blocks often start with blank lines. When a block is expanded but the previous block is not, these blank lines are hidden. If the selection is right after these hidden blank lines, tapping "Include pre lines" will include them in the selection.

Replace (Select)

The first input buffer is a regex. Each match within the selection is replaced with the second input buffer. <Enter> moves the cursor between the two buffers. Each replacement is indicated visually. (vim: :'<,'>s//g)

Cancel (Select > Replace)

Does not replace any of the matches.

Replace (Select > Replace)

Replaces each of the matches as shown in the text.

Replace case (Select > Replace)

When shown, replaces will attempt to match the case of the text they matched. For example, if replacing foo with bar, FOO becomes BAR, and Foo becomes Bar. Tapping will change the behavior to something else.

Replace exact (Select > Replace)

When shown, replaces will replace their matched text with the exact contents of the second input buffer. Tapping will change the behavior to something else.

Select lines

Like Select, except the entire line under the cursor is selected, and any line tapped moves the selection to include the entire tapped line. (vim: V)

Redo

Redoes the previous Undo.

Start of line

Moves the cursor to the start of its line. This will appear when you tap close to the start of the line.

Undo

Undoes the previous change to the text.

Main menu

Backups

Every file is backed up before it is opened. This screen will show you your backups chronologically, as well as how much space they are all taking up. Clearing them will delete them all. Tapping an individual backup allows you to view it Read-only, which you can then Save as somewhere and edit. Diff will show the difference between the backup and what is stored on disk. Restore will overwrite what is on disk with the backup's contents.

Create a file

Opens a new blank file. It isn't saved anywhere until you press Save and give it a location.

Decrease font size

Decreases the global font size by 10%.

Increase font size

Increases the global font size by 10%.

Licenses

Displays the licenses of code and assets used by MobileCode.

Log

Shows a debug log of MobileCode.

Open a file

Opens a system file picker to choose a file to edit.

Open a URL

Enter a URL to save its contents locally. If you copy the URL and then come back to MobileCode, it will offer to use the clipboard's contents as the URL. If the URL is a GitHub repo URL, it will download the default branch. If the URL ends in .zip, it will unzip it. Otherwise, it simply saves the contents of the URL as the file.

Every saved URL will be listed. You can see how much space they take up and delete them. When you tap one, if it is a directory, you can browse its contents for a file to open. Otherwise, the file itself is directly opened.

Recent

Every file edited is listed here. You can tap X to remove it from the history, or search to refine the results. Tapping an entry will open it and move it to the top of the list.

Resume editing <file>

The file listed is currently open, and tapping this will return to editing where you left off.