main.append(addParagraph("The vi editor has been around in various forms since the 70's and started life as ed. Notethat today, pretty much every installation of linux will have vim installed by default but it is usually invoked with the command vi. However, most installations will also have an alias (which you may have to enable in .bashrc or wherever your aliases are stored) which will allow you to invoke the editor using the vim command. There are still some installations that have vi installed as the editor so you may need to install vim separately."));
main.append(addParagraph("The easiset way to check whether your installation has vi installed is to sipmly invoke the vi command without a filename which will open the editor without a file. On my raspberry pi 5, this will open the screen shown in figure 1."));
main.append(addImageWithCaption("./images/figure1.png","Figure 1 - the screen displayed when invoking the \"vi\" editor using the vi commandon it's own."));
main.append(addParagraph("As you can see, this has opened vim which shows that vim is the default editor (or rather, it is the default version of vi - we do also have nano installed). On my system, I have a file called .bash_aliases which I use for my own personal aliases and this includes the line"));
main.append(addSyntax("alias vim='vi'"));
main.append(addParagraph("Without that, I may get an error stating that the command was unrecognised if I tried to invoke the editor with vi. In my case, both actually worked fine without the alias because I recently installed vim in order to install some other utilities such as vimdiff and that installs the editor again with the name vim (so you would find that in /usr/bin) which meant I had both vi and vim installed but both of these are installations of vim. I don't need both so I have removed the vim installation and now without the alias, I get the result"));
main.append(addSyntax("-bash: /usr/bin/vim: No such file or directory"));
main.append(addParagraph("if I try to invoke the editor with the vim command. With the alias in place, the editor can be invloked with either vi or vim."));
main.append(addParagraph("If you have a new installation and you get the vim editor appearing when you try to invoke it with vi but you get an error with vim, you can resolve this by either also installing vim or using the alias."));
main.append(addParagraph("While we are on the subject of problems with vi or vim when you have a new install, something you will commonly see is that some of the movement keys, particularly the arrow keys, do not work in vi and that can be a pain when you are trying to edit a file. There is a solution to that and that is to edit a file in your home directory called .vimrc. By default, this doesn't exist so it is most likely going to be a new file and you want to insert the line"));
main.append(addSyntax("set nocompatible"));
main.append(addParagraph("and save and that will resolve that problem. As you may have guessed, .vimrc is a file that vi/vim will read when it starts (if it exists) and it just sets your own personal config options for vi. There are other options you can and this file can get quite complicated, but for me it usually just contains that line. Now, getting back to the history of vi"));
main.append(addSubHeader("ed 1976"));
main.append(addParagraph("ed was a line based text editor used from a terminal, pretty much as vim is today."));
main.append(addSubHeader("ex 1977"));
main.append(addParagraph("ex was simply an extended version of ed."));
main.append(addSubHeader("vi 1979"));
main.append(addParagraph("vi was initally developed as a visual extension of ex but eventually became a separate editor and is pretty much the version still used today as vim."));
main.append(addSubHeader("vim 1991"));
main.append(addParagraph("vim was developed by Bram Moolenaar as an improved version of vi adding features like syntax highlighting, udo/redo, plugins and so on. It is maintained by the open-source community and has largely replaced vi as the default editor. You may still see some Linux distros where vi is the default, but those are likely to be older versions of that distro. Most distros nowadays would have vim as the default but for backwards compatibility, you may find that it is stil called vi and if you look in the /usr/bin folder, you might see that vi is there and vim isn't but the editor is vim as you can confirm by typing vi on it's own."));
addSidebar("linux");
sidebar.append(addParagraph("A link to <a href='https://www.linkedin.com/learning/learning-vi'>this course</a>."));