-
Notifications
You must be signed in to change notification settings - Fork 54
Getting Started
The vy editor is one of the most powerful text editors around. It has a great plugin API, a nifty scheme of keystrokes and it is extremely efficient in terms of hardware resources. The vy power comes at a cost, however: When getting started users face a steep learning curve.
I used to love vim it was so amazing to play around with its features and work with it. But i knew i couldn't take the best out of it if i didn't learn vimscript language. I tried learning vimscript but i hated it. I was a little bit young at that time and i was full of energy, for some odd reason i had this feeling that i could implement a considerable subset of vim features using python and tkinter in a short period of time.
Vy and vim share some similarities but they are quite different things, in vy there is no historical reason/backward compatibility, the code is just plain clean and objective, same about the keystrokes.
In vy you spend most time in 'NORMAL' mode like it happens with vim users, you switch to 'INSERT' mode only when you need to add or change some text. There are other auxiliary modes like 'ALPHA', 'BETA' etc.
I love vy for the same reason i loved vim and hated emacs, vy is much more healthy than emacs because the basic set of keystrokes is more handy. No need for many modifiers, if there is need for modifiers then they were chosen carefully.
This book goes through all standard cases of using vy as an editor/ide. It describes some possible scenaries in which the keycommands are useful as well as explain step by step how to use the keycommands.
This book should work as a complete introduction and a reference for vy editor. It covers all cases from keystrokes to implementing new plugins.
A modal editor is an editor that can be in different states. It performs different actions from each state it is in. When vy is NORMAL mode and you press:
<Key-j>
it will make the cursor jump one line down. When it is in INSERT mode and you press:
<Key-j>
it will merely insert the character 'j' at the cursor position.
The vy editor permits the implementation of new modes, it means that there could exist modes for programming languages, filemanagers etc.
Along this intro i'll use some terms like keycommands, AreaVi instances. A keycommand is a mapping between a keystroke event and a python function. When a key that generates an event is pressed and such an event is mapped to a function then a keycommand is performed.
A keycommand happens when there is a handle mapped to an event like:
<Key-i>
It means when you press 'i' in a given mode, vy will call a handle mapped to that event that corresponds to the mode in which vy is in.
It is possible to have multiple AreaVi instances that are in different modes. The mode statusbar field shows in which mode the AreaVi instance that has focus is in.
An AreaVi instance is a class instance of the Tkinter Text widget from which AreaVi inherits from. AreaVi implements new features that turn the Text widget more powerful.
Consider the following keycommand below:
<Control-h>
In order to execute the code mapped to that event one would keep the Control key pressed then press the key 'h'.
Consider now:
<Control-H>
What does it mean? It means that to perform the keycommand above then one would keep the key Control pressed then press 'H'.
The vy statusbar has fields to show messages, display the mode in which vy is in, show cursor line and column. Some keycommands display messages to inform the user of the success of an operation.
Once vy is installed then open a terminal then type.
vy
That is enough to have vy running.
The basic two modes of vy are NORMAL and INSERT. The NORMAL mode is in which vy starts. The INSERT mode is used to insert data in the AreaVi instance. In order to switch to INSERT mode from NORMAL mode you press:
<Key-i>
The statusbar mode field shows in which mode vy is in. Once you change to INSERT mode by pressing in NORMAL mode it would appear on the statusbar mode field: INSERT. You can switch back to NORMAL mode by pressing:
<Escape>
The NORMAL mode is where most basic functinonalities are implemented in. This mode offers all kind of handy keycommands like opening files, saving files, making the cursor jump to positions, searching pattern of text, replacing ranges of text etc.
The first thing you will want to learn is how to move around a file. When you're in NORMAL mode, you will want to remember the following keys and what they do:
Move the cursor one character to the left.
<Key-h>
Move the cursor down one line.
<Key-j>
Move the cursor up one line.
<Key-k>
Move the cursor one character to the right.
<Key-l>
Move the cursor to the beginning of the line.
<Key-o>
Move the cursor to the end of the line.
<Key-p>
Move forward one word.
<Key-braceleft>
Move backward one word.
<Key-braceright>
Move to the end of the file.
<Key-2>
Move to the beginning of the file.
<Key-1>
Move to the last edit.
<Key-minus>
The best way to learn is practice. Take a few minutes to try vy out. Open up a terminal and type vy filename. Enter insert mode and type a bit and then hit Escape to start practicing movement around the file. Once you feel you're getting the vibe of it, it's time to try some editing.