Pushing the boundaries of egotism since 2006!

Occasional insights into the mind of an awesomeness.

Archives Posts

Where’s my vi <textarea>?

August 15th, 2007 by grimboy

Is it this it? Well, if you think opening another tab in gvim, making me switch back and forth and keeping stuff in sync behind my back counts then well, you have low expectations.

How about this?

no particular redistribution rights are granted;

that means you do not have the right to use this on your own web site.

exceptions: Internet Connection, Inc. customers may use this application on any site they like. They may not grant redistribution or other rights to others. they may do this even if they (sadly) become no longer customers.

other rights may become available in the future.

http://src.internetconnection.net/vi/

I can use it if I buy hosting off a provider named “Internet Connection, Inc”? Really, other rights in the future? On some code served from the domain gpl.internetconnection.net? Ambassador, you’re ruining us.

Fine, fine. I’ll get over it. So, yeah, this?

While JS/UIX is open-source (JS-files and HTML embedding must be) it is not
public domain. All rights reserved (c) mass:werk, N. Landsteiner 2003.
You may download the files for private use, but you must not publish, serve or
provide this system in any form without the positive confirmation of the
author. All changes to the source code must be authorized. No warranty of any
kind is granted.

Disclaimer: JS/UIX is provided free of charge and on an “as is” basis, without
warranties of any kind, expressed or implied. Licensors have no liability with
respect to use of the product. The entire risk as to the quality and perfor-
mance of the product is borne by licensee, who assumes the entire cost of any
service and repair. This disclaimer of warranty constitutes an essential part
of this agreement. No use of the product is authorized hereunder except under
this disclaimer.

JS/UIX is NOT a free software (for reasons see the FAQ). If you are looking for
a powerfull but easy to use terminal interface have a look at
“mass:werk termlib.js”

Better put than the last one at least. But what’s the reasoning behind it?

The strict licence is mainly due to the very nature of JS/UIX by now:
Since any malformed code could corrupt the whole system, a greater variety of
distributed copies would render it merly impossible to secure any bugfree
version. Plans are for a totally rebuild version with true multitasking and a
secure userland domain. As this new architecture would allow for third party
extensions, this future version of JS/UIX could well be the start of an open
project under a more permissive licence.

Oh, I see. If you licensed your “Operating System” openly then there would instantly be chaos. Just about everyone and their dogs would fork it. They’d all write masses of really buggy code ‘corrupting the whole system’. Every time anyone wanted a toy operating system they’d always opt for these broken forks rather than the original. Oh, and once again, we can look forward to freedom sometime in the future.

Right, fine. Aha! This one is even encouraging me to download it. Hey, it has command mode, search and replace.

h, j, k, l, h, j, k, l — “Key not supported”! But you have vi *in* your name, handface.gif.

Onwards. Hmm? Wait, even ‘o’ doesn’t work.

Never mind. Ho hum. No commands, no search, the cursor sometimes looks like it’s places where it isn’t, there’s nothing telling you what mode you’re in, no numbers preceding keys. Apart from that pretty good. The best of the freely licensed ones in my opinion.

None of the freely licensed ones are quite good enough for everyday use. That said, I’m amazed nobody’s packaged one them up as a greasemonkey script or the like.

Any I’ve missed?

(Oh, and from a non-textarea point of view vimperator is pretty good.)

Archives Posts

Vim is teh awesombe!

December 1st, 2006 by grimboy

Vim
photo by lilit

I recently started using vim as my primary text editor. I’m no expert with it (yet) I’m just posting with some advice to other people who also want to do the same. But first, I’m going to tell you why vim is good.

  • Fast in terms of loading
  • Fast in terms of usage
  • Customisability
  • Expandability
  • Portability
  • Makes you feel all tingly when you do something in just a few keystrokes

Lots of people reject the idea of heavily keyboard and (human) memory reliant editors such as Emacs or vim because they have a steep learning curve. However, I’ve found vim’s learning curve to be pretty reasonable, and if you code professionally or even as a regular hobby then it’s worth taking the time to learn an editor that will speed you up.

Coffee & Cream
photo by hulksjedi

There’s a nice little vim configuration thing called Cream. From what I understand this comes in two components:

  1. A number of configurations and macros for normal vim
  2. Cream itself (still vim underneath, but even milder, vim on tranquillisers)

I find this quite useful in that it makes normal vim behave a little bit more with its macros. However, Cream itself is too mild, it’s like using a normal text editor.

So, in conclusion, Cream is good. Download it and install it, but use vim configured by cream. Don’t use just cream itself. Well, actually you can - in fact it’s a nice gentle introduction to vim. If you just want a normal text editor then I recommend you use cream itself. I used cream itself for a while in “expert mode” before trying to customise it and failing. One thing that annoyed me in particular while coding python was that “expand tabs” worked for a single document, then claimed it was on but had to be turned off and on before it would start working again. I also wanted to be able to have the exact same configuration everywhere. This includes stuff like SSHing into Dreamhost and doing a hot-fix on a website or messing around on my old computer underneath the deskTM that does odd jobs like backups, svn, trac and an IRC bot. I had trouble doing configuration for Cream itself and I didn’t feel in control. So really, Cream configured or not (g)vim itself was the only option for me.

School children in Sanorgaon
photo by phitar

Anyway, let’s rewind a bit. If you want to learn vim use the tutor. Invoke the tutor by opening a terminal or a dos prompt or whatever and entering vimtutor in it (this assumes vim is in your path). Do the entire tutor, then do it again. This is the only way. You probably won’t find it difficult but you may very well find yourself thinking “this is pointless, weird and archaic” every now and then. I know I did. However, your brain will know when to use various keystrokes magically1. Apart from the tutor I found this charming IRC style tutorial quite useful for a bit of light revision later on. On top of that there’s always the official vim tips repository which is useful for specific pieces of insight. This tip is particularly useful in a general sense as it is a compilation.

A Contraption
photo by tojosan

Ok, so now that you know this little editor that is fast in all senses of the word you’re probably wondering about one of its most loved features, its customisability. Firstly there is the .vimrc (or _vimrc on windows). This is something that I did mostly by example, there are a number of heavily commented .vimrc files out there so it’s fairly easy to just read through them until an option catches your eye. Here are two of my favourites. Obviously if you want to customise something in particular then you can search through help or fall back to teh interwabs.

Here’s mine:
" Kill all the tabs.
set ts=4
set sw=4
set et
set nu
set sr

" use +N/+P to cycle through tabs (the gui kind):
nnoremap :tabnext
nnoremap :tabprev

” autoindenting
set ai
” smartindenting
set si
” a in an indent insets ’shiftwidth’ spaces (not tabstop)
set smarttab
” if non-zero, number of spaces to insert for a

set softtabstop=4
” no real wrap during insert
set tw=0

” have the h and l cursor keys wrap between lines (like and do
” by default), and ~ covert case over line breaks
set whichwrap=h,l,~,[,]

” allow to delete line breaks, beyond the start of the current
” insertion, and over indentations:
set backspace=eol,start,indent

” have (and + where it works) change the level of
” indentation:
inoremap

inoremap
” [+V still inserts an actual tab character.]

” map ‘F12′ to change the pwd of vim to the cwd of the current file
noremap :cd %:p:h

” pyLint the python ‘compiler’
autocmd FileType python compiler pylint

” Purdy color scheme
colorscheme inkpot

Disassembled Plug
photo by jm3

Plugins are the next thing. This is pretty obvious, just get some from the official vim plugin repository and shove them in ~/.vim/plugin/ (or C:\Program Files\Vim\vimfiles\plugin\ on windows) and shove colour schemes in ~/.vim/colors/. My favourite plugins at the moment are (keep in mind that some of these are geared toward python/html stuff):

  • Colours Sample Pack - brings variety to the editing experience. Although I am quite settled on inkpot although matrix is good if someone else is in the room.
  • Subversion (svn) Integration Plugin, update with stupid star trek name - Means I don’t have to switch into a terminal as often. (Well I’d probably use :!svn … if I didn’t use this)
  • python.vim - Some python related menu commands. You need to shove the following in your ~/.vimrc au FileType python source ~/.vim/plugin/python.vim
  • runscript.vim - Again, saves me doing a terminal or !python moo.py …
  • Vim Taglist - Turns vim into a source code browser. Endlessly useful for large files.

The Halls of Stanford
photo by akash_k

Finally, I said at the beginning that one of my requirements was to have the same configuration across several machines. What I’ve done is made a vim repository in svn (I use version control for everything) which I check out on all the machines I want to have configured then svn co and ln -s bits of it it to various directories (on windows I just check out bits of the tree directly). I have the plugin and color directories in the repository. I also have a directory called common. When I said I was showing you my .vimrc I was actually showing a file called /common/vimrc in the vim repository. I then source it from all of my .vimrc files. On Ubuntu on my laptop my .vimrc looks like2:

source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

source $HOME/.vim/common/common.vim
set guifont=ProFontWindows\ 9

(Yes, I use windows shortcuts on linux)

Sunset de la Pollution
photo by tengis

In conclusion, I’m very happy with vim. It has replace notepad++ on Windows and a different editor every month on Linux. I like controlling everything with the keyboard, a keyboard is ordered. A mouse is chaotic and can easily just wander off into Firefox onto a Wikipedia article about conspiracy theories, or something similarly stupid. Also I’ve never quite been satisfied with using dialogs to do stuff (e.g. open files, change font), gvim provides this option, but I can just as easily do this by typing if I already know what I want3. Also being able to execute terminal/dos commands directly from an editor is unspeakably convenient. If you’re learning vim and want advice or have a question, or if you are a vimmer already and want to correct me on anything I’ve said, then scratch the itch and leave a comment.

  1. No, seriously.
  2. I’m not lying this time.
  3. I think using dialogs are like window shopping. Prompts are like entering a number into the computer thing in Argos4.
  4. Nation specfic references and corporate endorsement all in one. I must be turning into an evil.