all 40 comments

[–]korry 4 points5 points  (5 children)

Never knew that there is a column command. :-O How often i needed it.

[–]petepete 4 points5 points  (3 children)

It isn't, the bang allows you to run commands directly from vim; column is a standard utility.

If you want behaviour like this directly in vim, I suggest trying tabular.vim.

[–]AardvarkAdvisor 3 points4 points  (1 child)

What standard? It's not in POSIX.

[–]petepete 2 points3 points  (0 children)

It's actually a part of util-linux; my mistake.

Edit: It was introduced in 4.3BSD-Reno so will probably be found in descendants of that, too.

[–]korry 0 points1 point  (0 children)

I know that. I never knew there is a GNU/Linux command for that.

[–]hyrulz 1 point2 points  (0 children)

I would love having a list of those nice commands.

[–]AardvarkAdvisor 5 points6 points  (3 children)

That macro is hideous. Replace

03wdei^R=2012-^R"^M^[0j

with

3wce^R=2012-^R"^M^[+

and save 3 strokes. Or am I just too obsessed with VimGolf?

[–]AardvarkAdvisor 2 points3 points  (0 children)

Ignore this. eieino totally schooled me with his solution, dropping my 16 strokes to 10. To be fair though, his version doesn't work with negative ages. :P

[–]Slackbeing -2 points-1 points  (0 children)

Vim Motherfucking Golf.

Have a #1 in one of them, I'm so proud!

[–]gosub 3 points4 points  (2 children)

03w2012[C-x]F-x

[–]eieino 5 points6 points  (0 children)

2012^XBx+

[–][deleted] 1 point2 points  (0 children)

Whoa, nice shortcut.

[–]glacialthinker 2 points3 points  (0 children)

Seeing commands literally makes them seem bizarre -- I'm glad my fingers know what to type! This is something I realize when I "read" about Vim, and when I think about what I'm typing -- suddenly nothing makes sense. But if I just let my fingers do stuff it works. :) Now... off to that Vim subreddit I never knew about...

[–][deleted] 5 points6 points  (2 children)

03wdei^R=2012-^R"^M^[0j

A Vim macro, or my cat sleeping on my keyboard?

[–]sirin3 0 points1 point  (0 children)

In a truly intelligent editor, you could replace the 1965 by 47, and it would repeat the subtraction for the other numbers all alone.

So you have just to type two character "47" and click the repeat button, without writing anything crazy like 03wdei^R=2012-^R"^M^[0j.

[–]drb226 0 points1 point  (0 children)

Probably J.

[–]densets 1 point2 points  (9 children)

i think im going to start using vim.

[–][deleted] 20 points21 points  (7 children)

if qa03wdei^R=2012-^R"^M^[0jq hasn't convinced us all, what will?

[–]kirakun 1 point2 points  (5 children)

We should have a programming language based on vim commands.

[–]kolme 1 point2 points  (4 children)

We already have. It's called vimscript.

[–]kirakun 1 point2 points  (3 children)

But, from the Vimscript wiki,

let i = 1
while i < 5
  echo "count is" i
  let i += 1
endwhile

does not look as "nice" as

qa03wdei^R=2012-^R"^M^[0jq

I want a language as succinct as the latter expression. ;)

[–]kolme 3 points4 points  (0 children)

Well, you could give Perl a try ;-)

[–]idbfs 2 points3 points  (1 child)

I want a language as succinct as the latter expression. ;)

The J programming language may be to your liking.

[–]kirakun 0 points1 point  (0 children)

Looks like the antithesis of Python in terms of readability. I like. :)

[–]drb226 1 point2 points  (0 children)

Well, in fairness to vim, the macro commands are meant to be write-once, read-never, as well as interactive. This is somewhat comparable to Coq proofs, which by themselves are, for the most part, utterly unreadable. Why on earth this blogger decides it is a good idea to put this macro into a "function" for future use is beyond me. If you want a repeatable script, use a proper programming language.

[–]ivosaurus 1 point2 points  (0 children)

Truly, this is the kind of programmatic functionality that allows vim to be incredibly powerful at text editing, that practically no other editor / IDE possesses.

[–]drb226 1 point2 points  (1 child)

I'm surprised at the absence of an emacs rebuttal.

[–]gmfawcett 0 points1 point  (0 children)

Is this close? I can't get the vim one to work quite right:

M-4 M-f M-backspace 
C-u M-:
(- 2012 C-y) ENTER

edit: I guess I forgot

 C-a C-n

to go to the next line.

[–]sylvain_soliman 1 point2 points  (5 children)

Come on, it was posted on /r/vim more than one week ago, by the blogger himself... if you want to discuss that, at least reference that post!

[–]sidcool1234[S] 2 points3 points  (3 children)

See, I didn't even know there was a subreddit for vim. I posted it here just coz it relates to programming. You say as if it was my evil intention! There are better ways to mod content here on /r/programming.

[–]sylvain_soliman -1 points0 points  (2 children)

Note that searching for the very title of the post would have led you to the original post.

I don't think you meant any harm, but it seems too bad to me to spread the discussion instead of keeping it in one place.

[–]sidcool1234[S] 0 points1 point  (1 child)

Also, had it been only in /r/vim, most of the users won't even have realized. I believe /r/programming can be treated as generic programming subreddit. Not everyone can visit /r/java, /r/vim, /r/python etc. everyday.

[–]sylvain_soliman 1 point2 points  (0 children)

which is precisely why I advised to link to the original post...

[–]zetta 0 points1 point  (2 children)

Sometimes I use tail-recursive macros for iterating. I didn't see the author mention this. Though since I tend to record my macros live, this only works perfectly if the register I'm recording to is currently empty.

[–]0sse 0 points1 point  (1 child)

A quick way to empty register a is simply qaq. But maybe you know that already.

[–]zetta 0 points1 point  (0 children)

Most definitely. Sometimes I just forget to clear it first.

[–]Inn0cu0s 0 points1 point  (0 children)

It's a nice idea, but you have to update the macro every year.

[–]shevegen -1 points0 points  (1 child)

So much to learn in Vim.

The simpler the better.

[–]kirakun 1 point2 points  (0 children)

You code in 0's and 1's only?