Monday, November 10, 2008

getting colder?

Another gem (from pov of those of us who grep a lot) found in VIM documentation:

:help :colder

At first I thought that is another wit command but then realized that the name fits to :cnext and :cprev commands.

Snip from VIM documentation:

So far has been assumed that there is only one list of errors. Actually the
ten last used lists are remembered. When starting a new list, the previous
ones are automatically kept.


And the two commands are :colder (to go to previous results) and :cnewer (to go back to newer results).

P.S. "List of errors" is used in VIM originally for :make. Results of :grep are also interpreted as list of errors, what promotes grep into rank of compiler (:

Thursday, November 06, 2008

VIM tips exchange on Slashdot

Link.

Flamewars Alert. This is Slashdot after all.

Friday, October 03, 2008

[link] vim scripts

From Sander Marechal: My list of must-have vim scripts.

Sunday, September 14, 2008

Defining a user command: easy make invocation

This little thing:

command MM :exec ":make ".substitute( substitute(expand('%:p'), '\.[^\.]*$', '', ''), '^'.getcwd().'/', '', '')

defines a new VIM command ":MM" which does invoke ":make" with name of current file without extension. E.g. if you edit file "helloworld.c" and then type command ":MM" that would expand to command ":make helloworld"

Just in case I have also added stripping of $PWD (getcwd() in VIM universe) so that if you edit file from another directory, make would be called with relative path and Makefile from current directory would be used. That will not improve much make behavior, but if by chance you are using "cons", then that would work very well.

Edit1. Forgot to mention. VIM mandates that all user commands start with capital letter (all standard commands start with lower case letters). That's why I named the custom command "MM"

Tuesday, August 26, 2008

[link] 21 of the Best Free Linux Text Editors

21 of the Best Free Linux Text Editors

Unfortunately, VI and Emacs clones are not presented. Emacs itself is too bloated to be used by people who like to remain in control of their text editor - but there are number of decent Emacs clones.

From Wikipedia: Emacs clones and VI clones. VIM is listed in VI clones.

P.S. Most important Emacs shortcuts: Ctrl-g - end minibuffer editing, if any; Ctrl-x Ctrl-c - exit Emacs. Ctrl-g you need because often, after entering shortcut from another text editor, you might end-up in Emacs minibuffer (internal command line). Ctrl-x Ctrl-c will not work in minibuffer - so you need to press Ctrl-g. After exiting Emacs, type in shell "vim" and press Enter to start real text editor ^_^

Monday, August 25, 2008

[link] 100 Vim commands

100 Vim commands every programmer should know

Nice summary of vim commands.

P.S. Though apparently the people are messing up "vim" and "vi". As things stand right now, "vim" has absolutely nothing to do with "vi". Hey I worked in "vi" (on both Solaris 10 and HP-UX 11.x) - that was most frustrating 5 minutes in my life. The *NIX vendors do not even bother adding keyboard support. Solaris' "vi" proudly says that it wasn't updated since 1996.

Wednesday, July 09, 2008

little useful bit of info showcmd

How to see how long selection (visual) is?

How to see whether you have accidentally entered any numbers which would act as repeat counter for the command?

The little thing I always forget about:

:set showcmd

In right bottom corner (before ruler) little useful bits about actual state of keyboard input in normal are displayed.

Most useful is of course to now how long visual selection is, which I use often to e.g. count number of characters.

P.S. Documentation says the showcmd setting will be changed if you changed compatible mode. Shouldn't be a problem since no sane person uses compatible mode anyway.

Thursday, May 29, 2008

[off topic] Darn good quote

It's so much easier to suggest solutions when you don't know too much about the problem.
    -- Malcolm Forbes

[link] Sweeten your Vim with Cream

Simple Vim intro by Linux Magazine.

Monday, May 26, 2008

My personal minimal .vimrc

Another upgrade, another OS, another update... Well, new home directory - consequently new .vimrc.

Here is N hours into coding minimalistic usable .vimrc:


filetype plugin off
syntax on
imap <Insert> <Nop>
set bs=2 ruler title comments= nowrap
set cindent cinkeys-=: cinkeys-=0#
colo torte
let loaded_matchparen = 1
au BufReadPost * if line("'\"") > 0 &&
\ line("'\"") <= line("$") | exe "normal g'\"" | endif


I hope this time, Blogger/BlogSpot hadn't eaten any characters.
The set comment= creeped in before I have realized that filetype plugin is still on.