My first VIM script

I’ve switched over to vim for quite a while now (over a year now, I think), after being a die-hard gedit user. My productivity has gone way up since, but there’s always been something that’s bugged me: When you press , it always goes to the start of the line. Really, I want it to go to the first non-whitespace character, and if it’s already there, go to the start of the line (same behaviour as most modern graphical editors). After an unsuccessful twitter appeal, I decided to write my first ever VIM script to do this:

Putting that script in your ~/.vim/plugin directory, and then mapping it with

gives me my desired behaviour 🙂 It’s a pretty naive script, but it does the job.


Leave a Reply

Your email address will not be published. Required fields are marked *