Friday, July 6, 2012

custom commands executing a sequence of commands (macro)...

I'm learning VIM so probably this is a simple question for you...

I have created my first macro to generate getters from selected fields in a java file:
au BufRead,BufNewFile *.java let @g="^cwpublic2wyw$p2bcl() { return this.A; }2b"

So with a class:
public class Customer {
private String name;
private int age;
}

I can VISUAL SELECT "name" and "age" rows and press :norm @g and Enter.
Then I tryed with a key mapping (<Leader>get) and it runs.
au BufRead,BufNewFile *.java nmap <Leader>get ^cwpublic<ESC>2wyw$p2bcl() { return this.<ESC>A; }<ESC>2b

At the end I would like to do the same thing with a custom command called Jget
au BufRead,BufNewFile *.java command! Jget ^cwpublic<ESC>2wyw$p2bcl() { return this.<ESC>A; }<ESC>2b

This does not run. I tryed also with a "exe" after Jget, but nothing.
What am I doing wrong?

Thanks
R

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: