Creating and Using Keyboard Macros (Record Macro, Play Macro) to Record and Playback Keystrokes in Vim

  • In normal mode, press the key sequence q followed by a. This starts the recording mode (and you should see the word “recording” on the mode-line at the bottom).
  • Then enter or exit the insert-mode as many times as you wish, editing text using the keyboard. All the time, vim will keep recording all your keystrokes.
  • Finally exit insert-mode (get into normal mode) and then press q. This will stop recording your keystrokes.
  • Playback the recorded macro in normal mode, anytime, using the key-sequence @ followed by a. This will playback all the edits you made earlier. Once you’ve referred to a the first time, you can subsequently use @ followed by @ (a double @) to repeat the operation.

Instead of the key a following q when starting recording mode, you can really use any one of the keys 0 to 9 or a to z. The second key is basically a reference to a ‘register’ that sort of names your macro.  You can record multiple different macros and play them back by recording to each one of these ‘registers’. The key you use on playback after the @ refers to the appropriate macro recorded.

Recording and playback of keystrokes in Emacs is explained here.

  • Share/Bookmark
Posted in Uncategorized | Tagged | Leave a comment

Creating and Using Keyboard Macros (Record Macro, Play Macro) to Record and Playback Keystrokes in Emacs

  • Use C-x ( to start the macro (start recording keystrokes)
  • …Perform whatever keyboard actions…
  • Use C-x ) to stop the macro (stop recording keystrokes)
  • Playback the recorded macro anytime using C-x e

You can also assign different hot-keys for convenience:

(global-set-key [f1] 'start-kbd-macro)
(global-set-key [f2] 'end-kbd-macro)
(global-set-key [f3] 'call-last-kbd-macro)

Check out the KeyboardMacros Emacs Wiki page for more in-depth info on Emacs Keyboard Macros.

  • Share/Bookmark
Posted in Uncategorized | Tagged | 1 Comment

Getting rid of ^M (Ctrl-M) characters in Windows text using Vim

Text files created on Microsoft Windows usually use a combination of Carriage-Return and New-Line (CR-LF or \r\n) to separate lines.

When such text files are opened in Windows using Vim (usually in the Unix mode), the Carriage-Return’s will show up in the file as ^M (CTRL-M) and can be annoying specially when you are going through long text files. Note that though the ^M has two characters, Vim treats them as a single visible control character.

You can delete the ^M’s by moving the cursor over the caret and pressing ‘x’ in the command mode. Alternately, you can use Vim’s substitute command (used for search and replace) to remove all the ^M (CTRL-M) characters in one fell swoop.

To do the substitute action, in command mode, press “:” (colon, without the quotes) to start entering text on the mode-line at the bottom of the window.

Then, enter “1,$s/^M//g” (without the double-quotes) on the mode-line and press Enter. Presto, all your ^M’s are gone.

Do not enter the ^M in the above as a ‘^’ (caret) followed by an ‘M’. Instead, when it is time to enter this character, first press CTRL-Q to enter a mode where control characters can be keyed in and then press CTRL-M. This will actually insert the ^M (CTRL-M) as a special control character with the caret and the M (and which is treated like a single character though visibly it’s two characters).

To summarize, in command mode, type in the following

:
1
,
$
s
/
CTRL-Q
CTRL-M
/
/
g
ENTER

  • Share/Bookmark
Posted in Uncategorized | Tagged | Leave a comment

More than a little, less than enough…

“How much did you have to drink?”…”More than a little, less than enough”. Dialogue on Psych on USA. Nice. Either that or I am sleepy. It’s 11.22pm.

  • Share/Bookmark
Posted in Uncategorized | Tagged | Leave a comment

Effort Shock…

Read this blog post by David Wong. Fantastic insight –you may not agree entirely, it might seem like link-bait to market his book, etc. but fantastic insight nevertheless. Makes you think.

  • Share/Bookmark
Posted in Uncategorized | Tagged | Leave a comment

Connecting an Apple Cinema Display to a Windows XP Laptop

Recently I was trying to figure out if I could connect my old laptop which has VGA output to an Apple Cinema Display from a couple of years back that has a DVI-D connector/cable and I found out that you really cannot unless you buy a VGA-to-DVI-D converter.

Such a converter is not a simple adapter. Instead it is an analog-to-digital signal converter. Something like this.

Also from what I found on the Internet — you really want a very good converter since the digital signal requirements are very stringent. Unfortunately such converters are expensive $300 and up — for that price you can simply buy a new LCD monitor compatible with your laptop.

  • Share/Bookmark
Posted in Uncategorized | Tagged | 2 Comments

Building JSure on Ubuntu

I needed to do the following additional steps to get JSure: The Javascript Checker (Version 1.0.0 from http://www.jsure.org) to build on Ubuntu (8.04, hardy).

  1. I did not have ocaml installed — I need to run “aptitude install ocaml“.
  2. The build was failing with errors referring “ocamlopt.opt” — I had to modify all references to “ocamlopt.opt“, “ocaml.opt” and “ocamldep.opt” to remove the “.opt” in the Aurochs build file myocamlbuild.ml.
  3. The JSure build was giving me “/usr/bin/ld: cannot find -lgdbm_compat” errors — I had to make softlinks in /usr/lib to the version specific libraries that linker/loader was complaining about (ln -s libgdbm_compat.so.3.0.0 libgdbm_compat.so)

The other instructions at the JSure web-site also need be followed.

  • Share/Bookmark
Posted in Uncategorized | Tagged | Leave a comment

Insightful blog post

Relying on other people’s feedback is a nifty shortcut that became hardwired into our postmonkey brains.

In a blog post with a mundane title, Zachary Burt makes very keen observations.

  • Share/Bookmark
Posted in Uncategorized | Tagged | Leave a comment

Quote

It’s So Hard When Contemplated In Advance And So Easy When You Do It

  • Share/Bookmark
Posted in Uncategorized | Tagged | Leave a comment

Wes Anderson directed most of “Fantastic Mr. Fox” by e-mail!

I was reading this movie article about the movie “Fantastic Mr. Fox” in the weekend section of my newspaper (review by Chris Lee of the Los Angeles Times) and I was shocked to read about “…Anderson’s unorthodox choice to direct most of “Mr. Fox” via e-mail from his apartment in Paris”. Wow! More respect for Wes Anderson…we all know how doing things by email goes. The director of photography for the movie comments “..Whereas here, you’ll try to get something right. It’ll go back. It’ll be wrong. The feedback is blind, essentially.” The movie is nice, BTW. George Clooney’s voice is perfect for Mr. Fox. Sort of old-fashioned.

  • Share/Bookmark
Posted in Uncategorized | Tagged | Leave a comment