This page was last updated on March 13th, 2020(UTC) and it is currently May 30th, 2023(UTC).
That means this page is 3 years, 78 days, 2 hours, 34 minutes and 45 seconds old. Please keep that in mind.

23 - VIM Before we do anything else, we need a program that we can rely on for editing files. You could use the editor of whatever OS you're using to run your DOS emulator, at which point you might be able to just skip this lesson. I recommend, however, that you do learn how to use vim, anyway, as it'll work with just about any computer with a command line interface, which is useful in a pinch when working with a computer over SSH, which is usually how I develop, anymore (It's also how I'm writing this tutorial.).

Vim is a raw text editor for command line, which has alot of features. I don't even know all the features of VIM, and most tutorials seem to focus on things that most people will never use, while not going over things that most people will use. I do recommend taking the time to look at other tutorials, anyway. Vim usually comes with a tutorial inside of it, anyway, but it tries to cover everything, and thus you could easily spend a long time learning VIM when, right now, your interests are elsewhere. Vim has a bunch of different "modes," the main 4 you'll be using being "normal," "insert," "command line," and "visual."

By default, you'll be in "normal mode." Normal mode can be a bit crazy for people who are new to it, 'cause they desire to start typing immediately, and often find themselves unable to, and causing strange behavior when they try. Normal mode allows you to use various button presses to switch modes and "move the cursor" and a bunch of other things. For right now, with normal mode, you want to avoid hitting anything other than "i", ":", "/", "v", "d", "shift", "u", the arrow keys, or "p". "i" changes to "insert mode," while ":" and "/" change to "command line mode," while "v" changes to visual mode, "d" deletes a line (which also copies it, but i recommend using visual mode for this), "u" for "undo," and "p" for "paste." "Shift" modifies these functions (and the other ones), so I'd look more into this if you feel you really need, but that's beyond the scope here.

In insert mode, you basically type as you would expect. To leave insert mode, you must either use "escape" or ctrl+"[" to return to normal mode. Visual mode is more or less normal mode, except you can return to the real normal mode the same way you leave insert mode. Visual mode gives more features, but the main usage is that visual mode allows you to select text, including multiple lines, which can then be used with paste in normal mode to allow copy and paste.

If you entered command mode with "/" you're basically typing a search. If you know regular expressions, you can use that knowledge here, as well. Hitting "enter" will allow you to commit to that typing, and you can use "n" to "find next occurence." If you entered command mode with ":" you can type in various VIM commands afterwords. The main ones you should be concerned with, for now, are "w" for "Write [save]" and "q" for "Quit." Sometimes it won't want to do either of these commands (like if you changed the file and didn't save first), so you put "!" at the end and it'll likely comply. You can use "wq" to "save and quit." Generally, I create a file by using the filename as an argument. If the file already exists, it'll attempt to edit the file instead. Do not forget to add an extention to the filename (.txt for example) if relevant.

Get your own web kitty here!
©Copyright 2010-2023. All rights reserved.