Blogged by Ujihisa. Standard methods of programming and thoughts including Clojure, Vim, LLVM, Haskell, Ruby and Mathematics written by a Japanese programmer. github/ujihisa

Wednesday, February 3, 2010

The Right Way of Running External Commands on Vim

Today I was struggled with one of the worst behavior of Vim script.

Try the following code on your Vim.

:!echo "#!"

Assuming you know that the command :! is to run the given command on your shell. This looks equivalent to

$ echo "#!"

on your terminal.

But Vim will show a cryptic error. That's because both # and ! are special letters for :! command.

  • ! is the command previously ran. This is for the pseudo command :!! which means that running the same command again.
  • # is the filename previously you edited.
  • Similar in %

They may be useful for using Vim, but they make Vim script programmers crazy.

No comments:

Post a Comment

Followers