viSugar has a built in text editor that you can use with the Terminal Activity. This editor is called vi and is used in many other types of operating system such as Linux. Lets have a quick look at vi : type vi in the terminal and you will see something like this:
This is vim running inside the terminal. You can use vim as a text editor so that you don't need to open any other Activities to read or write most documents.
Open a Text File
|
| command | action |
|---|---|
| i (only used in read-only mode) | insert text |
| :w (only used in read-only mode) | write changes to file |
| u (only used in read-only mode) | undo changes |
| :q (only used in read-only mode) | quit vim |
vi always opens a file initially in read-only mode. This means that when you first open the file you cannot change the file. It is in this mode that you type the commands. At anytime you can press the 'esc' (escape) key to return to read only mode.
Lets look at some examples. First we open a file as we did in the above example :
vi MyExample.txt
This will open the "MyExample.txt" file as explained above, or creates a new (blank) file if it did not already exist.
You can scroll up and down the file using the up and down arrows on your keyboard.To insert new content or change the existing content of the file in vi you need to type :
i
This will put me in the insertion mode and now anything I type will appear in the document itself. When I have finished making the changes I may wish to save the file. I would then press the "esc" key followed by :
:w
This will write the file with the new changes. I then need to quit from vi so I press the escape key followed by :
:q
Now find a file and experiment. If you haven't used something like vim before then it might take some getting used to, so spend some time working out for yourself how vi works before you really need to use it.