Close

Vi IMproved

VI is a key text editing tool available on unix systems. The most common version of vi used by desktop linux distributions is VIM. There are a number of implementations of the modal vi editor but I have learned and use the most common one, VIM.

Having a consistent and capable editor available on any system is important, especially important for people who move from machine to machine for whatever reason. People who administer UNIX systems or who help others with their operating system (like many Linux User Group members) need to edit files quickly. The family of editors known as vi (including nvi, aka. vi on BSD) is very useful for this. Some of the reasons for its success are the use of classic UNIX philosophy, regular expressions, keyboard use (no mouse required) and plugins. The learning curve is a bit steep for beginners. Because text editors are written for use in terminals they can be used even across platforms with the help of fink (brew and others) on Mac OSX and cygwin on Windows. Text editors are clearly not WYSIWYG word processors.

I like vim and I am biased. I’ve answered questions in #vim on Freenode. I’ve customized my installation with a personalized color scheme. I’ve written functions for use in my statusline. I use set ruler number hlsearch laststatus=2 cmdheight=3 and syntax on. I’ve googled and read other people’s vimrc files more than once. Over the years I’ve cobbled together configurations across many different machines. I’ve typed the vim command :help a lot. I’ve installed and used quite a few vimscript plugins and am still pleasantly surprised to find a new one that suits my needs well as my needs change. I’ve experimented with more modern ways to install plugins using git revision control rather than the traditional way of putting downloaded copies of files into a $HOME/.vim directory. I’ve written a little vimscript. I’ve played a couple games inside vim. I’ve tried my best to teach vim to a number of people in person.

The commands used for editing with vi and vim can come up in the most interesting places. The wikipedia article covers the history well. There are quite a few references to our home, Berkeley. A small version of vi is included with Cisco products. Perhaps we might be able to find some UC Berkeley and O’Reilly sponsorship to develop a vi* unconference style celebration in 2016 as vi/ex turns 40 years old!

What’s the best way to get started with vim? vimtutor is a great self-paced tutorial experience. Firing up vim and typing :help will provide you with the online documentation and instructions. Much has been written and said about vi and vim elsewhere. Mike Saunders of Linux Voice produced a great 12 minute video Learn to love Vim. It was featured on the front page of Linux Voice and encouraged me to write this article. The cheat sheet he referenced is fantastic. The related youtube videos also look interesting. Time and patience are really all that’s needed though these things seem to be in shorter supply than they used to be. While there is a learning curve it is worth it. Two friends, Michael and Jim, have both taught vi professionally.

A number of books are available notably from O’Reilly, New Rider, Packt and Pragmatic Bookshelf. At least one has a PDF download available. Purchasing from that page provides donations to Bram Molenar’s favorite charity, the ICCF-Holland which helps needy children in Uganda. Having seen firsthand some needy children in Kenya I encourage and support the works of ICCF-Holland.

This article should in no way be interpreted as a negative statement about other editors of any kind. gedit, nano, elvis, BusyBox’s clone and nvi are other common text editors. I am focusing here on text editing, not other differentiated text needs such as word processing. There are many good editors, most with highly specialized features for particular uses and/or for particular environments. Yet few other editors can be so well customized and are as universally available as vim. Code focused integrated development environments (IDE) also need to edit text and have many helpful features to write code. After scratching the surface I found that many features can be added to vim with some effort.

While emacs is powerful and comes to mind, emacs is not as universally available. While I learned some of the basics of emacs over the years and spent a period of time learning emacs many moons ago, I am not an expert. I realize that the emacs approach of not using editing modes (modes are used by vim) has advantages. Are you an emacs user? We welcome your blog post submissions.

I hope this article sparks informed discussion. Believe it or not, the choice of text editor has been known to elicit long discussions in some circles though this is far less prevalent now. People who work with text editors know that the choice of an editor can dramatically affect efficiency. Informed comments are encouraged.

We meet at Bobby G’s Pizzeria on the second and fourth Sundays of each month from Noon to 3PM in Berkeley near the Downtown Berkeley BART station. Bobby G’s is very close to the corner of University & Shattuck. We hope you join us, join the discussion on our email list and/or join us in #berkeleylug on freenode.net by following the tabs at the top.

LinkChecker

I found a broken link on another website I maintain. I quickly surveyed the available solutions and chose to try the Python based LinkChecker instead of the other perl or ruby based solutions. I wanted something I could use from a command line, run locally and possibly script. WordPress has it’s own plugin for this called Broken Link Checker which I enjoy using on a couple of other websites I maintain.

After installing linkchecker under my local user I found that the invocation is pretty straight forward. Output options are numerous. By default it checks internal site links. I then found the --check-extern option which is what I was looking for to check all the external links. By default ten threads are used at a time. While this option is good I haven’t had time to try out all the other options available.

The first link checker people often hear about is a perl script available via CPAN and hosted as validator.w3.org/checklink. Another perl option is linklint.org. The Python based twill scripting language for web browsing looked intriguing. The Ruby gem link-checker was published a few years ago and caught my attention but I have more experience with Python than Ruby. I am sure readers of this blog post would love to hear about the good and bad experiences of others using these and similar tools to keep the links on their websites from pointing to bad URLs.

We meet at Bobby G’s Pizzeria on the second and fourth Sundays of each month from noon to three in Berkeley near the Downtown Berkeley BART station. Bobby G’s is very close to the corner of University & Shattuck. We hope you join us, join the discussion on our email list and/or join us in #berkeleylug on freenode.net by following the tabs at the top.