Posts Tagged ‘vim’

Gits and Bugs

October 24th, 2011 subogero 2 comments

One may wonder what was happening in the last few months. Everyone knows about the Euro-crisis. A certain Mr Erdogan has been trying to revive the Ottoman Empire, sharpening his Unix-skills, especially bashing, on Israel.  Mahmoud failed to turn Judea and Samaria into a Judenrein state at the UN. It also turned out that a single Israeli soldier is worth 1027 heroic Palestinian freedom fighters. What’s more, Muammar Kadhafi, in a markedly Perl-like fashion, said:

keep $power or die $!

Yes, but what about the real important stuff, you may ask. Oh, I see what you mean! Here it is.

I needed a recursive git-grep function to scan submodules as well. So I wrote one. Along with a vim-plugin, which is a beautiful piece of plagiarism, but that’s open source for you!

I got acquainted with gdb, the GNU Debugger, courtesy of Richard Stallman. Typical of him, it prints 2 pages of licensing info and political agenda when started up. But after you get rid of that,

alias gdb='gdb -q'

what a brilliant piece of software it is! Easy, comfortable, fast, debugging on the command line. It’s just incredible. Gdb is a bit better explained here:

I rewrote my calculator, because one had to type too many uppercase letters for hex numbers. It’s all lowercase now. And it’s called “szg”, and no, not after my initials. It means SZámolóGép, which is Hungarian for calculator. Nothing to do with Hungarian notation, though. Which one of my colleagues turned out to actually like. Strange taste. It must give a deep satisfaction, when after 2 years of maintenance “u8Foo” has become a signed long.

Anyway the new calculator is available on github:

At the office, I’m now co-developing a rather large project in git with a colleague. Lots of fun…

Having mentioned Muammar Kadhafi, there was a lot of hype about the death of Steve Jobs recently. A much more important person has passed away too: Dennis Ritchie, creator of the C programming language, co-creator of Unix with Ken Thompson. As a tribute, some quotes from the two heroes:

Obviously, the person who had most influence on my career was Ken Thompson.
Dennis Ritchie
That brings me to Dennis Ritchie. Our collaboration has been a thing of beauty.
Ken Thompson 
Categories: Uncategorized Tags: , , , ,

Cheat Sheets

July 15th, 2011 subogero 1 comment

This is the collection of cheat sheets I’ve uploaded to other posts and pages. I’ve been thinking about the format a good deal and ended up going for something I otherwise frown upon: the Open Document Format. Why?

  • PDF? I hate it even more, and users can’t edit it
  • HTML? Can’t control the printed format, not dense enough
  • Plain text? Can’t format chapter titles to stand out, thus non-navigable with the eye
  • DOC? Come on…
git Cheat Sheet

git Cheat Sheet

vi Chet Sheet

vi Cheat Sheet

Copyright notice: All rights reserved. The cheat sheets can be copied, distributed, printed and modified only with the explicit written permission of the copyright holder.


Categories: Uncategorized Tags: , , ,

vi Cheat Sheet

July 4th, 2011 subogero Comments off

I’ve just reached a very severe stage of the disease called Unix. I’m learning vi.

I still vividly remember the shock when a command-line Linux expected me to edit something and kindly opened up vi for me. I did not know how to exit, so I had to shut down the computer.

After using pagers (more or less) and manual pages for some time, I slowly learned a few important hotkeys like “/pattern” to search forward for something, “n” to find the next match and “q” to quit. Playing the command-line version of robots, one quickly memorizes “h”, “j”, “k” and “l” for navigation. It turns out they all come from vi. Or vice versa.

But before going on, I’d like to enlighten my readers about quitting vi:

:q<Enter>   Quit
:q!<Enter>  Quit and discard changes
:wq<Enter>  Save and quit
ZZ          Save and quit

Now that quitting is out of the way, let me tell you about a few highlights of my steepish vi learning curve. It seems the usefulness of Unix tools is proportional with their scariness.  Same as with git.

Those 1-2-letter commands are quite logical, actually, usually consisting of a command and a move, eg “dw” stands for delete word.

Let’s take moving around in the window. After scrolling down a few pages, you find the interesting line, but it’s in the bottom of the screen along with the cursor. Command “z.” will put it in the middle.

When you try to select something with a Windows-style editor, you press Shift at the beginning, keep it pressed and move around with the arrows. Then you realize the beginning is at the wrong position. You can start over.

In vi, on the other hand, you press “v” for visual selection, move around to find the end of the highlighted block. Then you notice the beginning is wrong. Press “o” for opposite, your block’s end will get fixed and the cursor jumps to the beginning, which you can now move around. Astonishing!

And now to something completely different: the vi Cheat Sheet!

vi Chet Sheet

vi Cheat Sheet

Bonus: I was always wondering what text editor I should install onto my Android phone. I’ve just realized that busybox-vi has been there all the time. It works perfectly with the crude virtual keyboard.

Bonus 2: my ~/.vimrc file with syntax highlight, line numbers, autoindent, highlight search results and, most importantly, brighter foreground colours.

syntax on
set number
set autoindent
set hlsearch
set background=dark
Categories: Uncategorized Tags: , , , ,