Skip to main content
Version: 0.1.2

First Steps in Rsvim

Start

To start Rsvim, open terminal and enter this command:

rsvim file.txt

Rsvim starts editing a file called "file.txt", because this is a new file, you get a blank window. The terminal will look like:

+---------------------------------------+
|# |
| |
| |
| |
| |
| |
+---------------------------------------+
note

'#' is the cursor position

When Rsvim starts, it by default opens a file buffer and a window. A file buffer loads the file content from file system into memory, a window is a text view for the binded buffer. If no file name(s) are provided, Rsvim opens an empty file buffer without file name. If the specific file doesn't exist in file system, Rsvim opens an empty file buffer with the specific file name.

Inserting Text

Rsvim is a modal editor, which means the editor behaves differently, depending on which mode you are in. At any given time, the editor would be in exactly one mode. The 2 basic modes are called "normal" mode and "insert" mode. In normal mode, the characters you type are commands. In insert mode, the characters are inserted as text.

After Rsvim just started, it will be in normal mode. To start insert mode, you type the "i" command ("i" is for "insert"). Then you can insert text, it will be inserted into the file buffer on current window where the cursor is in. The file on file system won't be written unless you saved the file buffer. Let's enter the programmer's limerick:

iA very intelligent turtle
Found programming UNIX a hurdle
note

The first i indicates starting insert mode

After typing "turtle" (last word in first line), you press <Enter> key to start a new line. Finally you press <Esc> key to exit insert mode and go back to normal mode. Now you have 2 lines of text in your window:

+---------------------------------------+
|A very intelligent turtle |
|Found programming UNIX a hurdle |
| |
| |
| |
| |
| |
+---------------------------------------+

Moving Around

After you return to normal mode, you can move around by using these keys:

  • h and left
  • j and down
  • k and up
  • l and right

At first, it may appear that these commands were chosen at random. After all, who ever heard of using "l" for right? But actually, there is a very good reason for these choices: Moving the cursor is the most common thing you do in an editor, and these keys are on the home row of your right hand, assuming you are on the QWERTY keyboard layout. In other words, these commands are placed where you can type them the fastest (especially when you type with 10 fingers).

Deleting Characters

To delete a character, move the cursor over it and type "i" to start insert, then type "backspace" to delete a character on the left, or type "delete" to delete a character on the right. For example, move cursor to the beginning of the first line, type "i" to start insert mode, then type "delete" for 7 times to delete "A very ". The result should look like:

+---------------------------------------+
|intelligent turtle |
|Found programming UNIX a hurdle |
| |
| |
| |
| |
| |
+---------------------------------------+

Now you can insert new text, for example by typing:

iA young <Esc>
note

The first i indicates starting insert mode, the last <Esc> key indicates returning back to normal mode

It starts insert mode (by i), and inserts words "A young ", then exits insert mode (by <Esc>). The result is:

+---------------------------------------+
|A young intelligent turtle |
|Found programming UNIX a hurdle |
| |
| |
| |
| |
| |
+---------------------------------------+

Appending

The i command starts inserting under the cursor, while the a command starts inserting after the cursor. For example append "!!!" at the end of this line:

and that's not saying much for the turtle

Move the cursor to the end of the line, at the last e character, type:

a!!!<Esc>
note

The first a indicates appending, the last <Esc> indicates returning back to normal mode

The result is:

and that's not saying much for the turtle!!!

Opening Up a New Line

The o command creates a new, empty line below the cursor and starts insert mode. Then you can insert text for the new line. For example, the cursor is at the beginning of the first line:

A very intelligent turtle
Found programming UNIX a hurdle

If you now use the o command and type new text:

oThat liked using Vim<Esc>
note

The first o indicates opening up a new line, the last <Esc> indicates returning back to normal mode

The result is:

A very intelligent turtle
That liked using Vim
Found programming UNIX a hurdle

Save Your Work

All the editings only change the in-memory buffer content, they will not be saved to file system until you execute so. For example, once you are in normal mode, to save the current buffer to file system, type:

:js Rsvim.buf.writeSync(Rsvim.buf.current());<Enter>
note

The first : indicates starting the "command-line" mode, the last <Enter> indicates confirming the input ex command and returning back to normal mode

Now you can verify the file changes in file system.

Quit

After saving the file, you exit Rsvim by typing:

:js Rsvim.rt.exit();<Enter>
note

The first : indicates starting the "command-line" mode, the last <Enter> indicates confirming the input ex command and returning back to normal mode

Now you can go on with other works.

Question

Where are the :w and :q ex commands? Aren't they much shorter and easier for users?

Yes, :w and :q are better than :js with super long expressions. Currently, only one builtin ex command :js is provided, users are limited to do it this way.

Because Rsvim will not embed any builtin plugins, including the ex commands (:w, :q, :echo, etc). On the contrary, Rsvim will provide APIs such as Rsvim.cmd.create() to allow user create their own ex commands.

As a supplement to the editing experience, Rsvim will provide an official plugin (say, "ex.rsvim") to recreate all the commands compatible with Vim/Neovim, including :w, :q, :echo, etc.