Thursday, August 31, 2006

Dangers of Wikipedia

That damm Wikipedia thing is addictive. It must be outlawed. Once you start reading it - page after page, link after link - you cannot stop.

Anyway. Pretty nice opinion from Tim O'Reilly about why he is vi guy.

Replace "emacs" with "random Wind0ze GUI IDE" - and what he said would be true to me too.

P.S. As for me, "Emacs vs. VI " holy war really comes down to "all-in-one v. modularized" debate. Or from another POV it can be seen as "shell vs. emacs lisp": to Emacs lisp is what shell to Unix. I like VIM since it works with shell directly - it does not have any layers distancing user from OS. I guess if one doesn't like shell but likes elisp instead - then Emacs may be the way to go.

Cult of vi

Cult of vi has among other interesting references the chart of vi commands.

P.S. :g/^/m0/ and ZZ look like fun!

VIM @ Wikipedia

VIM's Wikipedia Page

Off-Topic: dumping gcc/cpp predefined macros

echo | gcc -dM -E -

-dM tells cpp to out #define for every variable it has.

-E tells gcc to run cpp only

P.S. I dead tired to dig documentation every time I need to find how platform is identified by GCC. So putting that stuff here in hope that it would be easier locatable.

Monday, August 14, 2006

vim :: repetition counter (and period command)

One of the funniest (and obscure) VIM features is repetition counter. Most of the commands allow the counter. Consider example (that needs to be typed in in normal mode):


The VIM's command 'l' is the command to move left (VIM supports motion keys as in old time games - 'h', 'j', 'k' and 'l' are correspondently left, down, up and right.) Prepended to it '20' is the repetition counter. If cursor was in position 1, after the command it would be in position 21 (or on end of line if it is shorter).


Would delete 1000 lines starting from current.


Would move cursor to third space in line, counting from current cursor position. (:help f for find motion command.)

It is very useful at times for example combined with command '.' which is used to repeat last command(s). Example how to make a nice C comment with 50 dashes.

I intentionally made typing of dash separate, thus it can be later repeated with '.' command. I yet to gain complete understanding on how '.' works precisely, but in most obvious cases it works as expected. :help . for more info. Experimentation plus 'u' undo command could help to get it right.

More info can be found in VIM under :help count & :help repeat.txt.

Friday, August 11, 2006

vertical selection from Nth to Mth character

ZOMG! I got e-mail. That stuff apparently got indexed by Google. So. Here we go.

I do have a question for you, however. When performing a vertical selection, is there any way to advance the screen other than the arrow keys? For instance, if a file were thousands of lines long, is there a way to quickly select characters 10 through 20 for the entire length?

All motion shortcuts must work as usual. (:help motion.txt) In other words. To select vertically across all lines in the file chars 10 to 20 you need something like that (those " are comments):

gg " move to beginning of file, beginning of line
9l " move to 10th symbol in line (l == move 1 char left,
" 9l == move 9 times chars left)
^V " start vertical selection
G " move to last line of file, beginning of line
19l " move to 20th symbol in line.

now y/d/whatever to yank/delete/etc. IOW, no magic - standard shortcuts. I hope that answers your question.

Though there might be problem: if last line of file shorter than 20 characters, or if first line shorter than 10 characters, or tab character is sitting somewhere there - VIM wouldn't be able to do precisely what you want it to do.

P.S. For later case shell comes in handy: man cut for -b & -c options. Using redirection and intermediate file you can get you part into separate file and then open it (along with original) in VIM - and use normal line blocks. With combination of head and tail (man head & man tail) you can get from file lines you need.

Thursday, August 10, 2006

vim :: turn that 'showmatch' crap off

I have just waisted hour to find that sucker:

set noshowmatch

SUSE (as well RedHat) have long tradition of shipping f*cked up configs for all major editors and terminal emulators. SUSE 10 (in addition to unusable xterm config and vim's "set backspace=0" (which renders backspace key in vim totally borken)) now started adding "set showmatch" to default exrc. As if anybody over there at SUSE/Novell actually used once xterm or vim. Why they keep crapping in the configs?? Are GNOME/KDE configs not enough for distros to shit into???

set showmatch, if you have just typed parens/bracket/comment opening/etc, makes cursor to jump shortly to its counterpart. That shit is creping off Wind0ze over-bloated unusable IDEs. It distracts your attention of what you were doing. It forces you to move your eye - as if you do not know your own source code - needlessly, wearing and tiring them down. Might it be OS vendors have a secret contract with ophthalmologists??? I have no other guess.

P.S. Linux Productivity Magazine, Volume 1 Issue 5, December 2002 "VI and Vim" - - lots of vi/vim basics.

Edit1 Related: matching parens highlighting. Mistakenly attributed to VIM7, but also present in VIM6.

Edit2 Proper fix