Breaking infinite loops in VBA

I do a lot of Visual Basic for Applications (VBA) development in Microsoft Office. Any program can get stuck in an infinite loop, and when my VBA programs have it has always meant data loss. The Internet to the rescue, as of not quite a month ago!

To break VBA code execution, at least in Office 2013, hit Ctrl+Scroll Lock. ¬†Obvious, right? ūüėČ

Huge thanks to¬†MSDN user povidla, who posted this solution in¬†the MSDN forums. ¬†Povidla, if you’re reading this, please comment so I can thank you directly!

Edit I have found that, in some situations, this doesn’t work unless there is a DoEvents call to catch the Ctrl+ScrLk. ¬†If you have a loop that might be infinite, sticking a DoEvents in it is probably a good practice.

Greetings to Stack Overflow users!  I keep hoping that Povidla will find this page.  If you happen to know who Povidla is, please pass along a thank you from me.  Regardless, thanks for reading!

GIMP paths tutorial

This¬†GIMP path tutorial¬†today taught me¬†how to close a path ‚ÄĒ basic, but not the most obvious thing I’ve ever done on a computer. ¬†Though the look of GIMP has changed somewhat since the tutorial came out, at least path-closing still works the same way! ¬†(Ctrl-click the first point, in case you were wondering.)

Adventures in vim

Forgot to mention — if this is all Greek to you, don’t worry! I’ve been learning from fellow Vim users and sharing tips since the late 1990s. Give it time; it will come.

Following up on¬†last time¬†— you can also use motions like ip with : commands that normally take ranges.

Type v<motion>, where <motion> is ip or G or some other cursor motion command. Vim will highlight the text from the cursor to wherever <motion> takes you. (If only vim had a motion key for second star to the right and straight on ’til morning!) You can then issue any : command and it will operate on the selected text.

I often use external sort or fold utilities via filter commands. Those are even easier – you don’t even have to type the :. For example, vip!fold -s -w 70<Enter> folds long lines in the current paragraph. Sure beats what I used to do, which was {:.,/^$/!fold -s -w 70<Enter>! (Makes total sense, right? ūüôā )

Adventures in vim

Vim is my text editor of choice.  (emacs users, commence flaming!)  Yesterday I discovered ip and today I discovered Control-O.  Best shortcuts ever!

ip selects the current paragraph, delimited by blank lines unless you set the modes otherwise.  I used to select whole paragraphs with {y}, which copied extra lines and lost my cursor position.  Now I can copy with yip, which grabs just the paragraph text and keeps the cursor firmly planted.  Fantastic!  See :help object-select for more.

Control-O is a get-out-of-insert-mode-free card. ¬†When inserting, hit Control-O and you’ll be back in command mode for the duration of one command. ¬†That can be a colon or immediate command. ¬†For example, <Ctrl-O>f, will jump you forward to the next comma — without leaving insert mode. ¬†Esc, w or f or / or what have you, i has been my everyday for years. I am thrilled about saving one keystroke per such action times ~1e100 actions over my vimming life. More at¬†:help ins-special-special.

Stay tuned for more adventures in vim!