Wednesday, February 20, 2013

Re: vim script: repeat(\)

On 02/20/2013 02:30 PM, Ben Fritz wrote:
> On Wednesday, February 20, 2013 1:14:14 PM UTC-6, ping wrote:
>> nn ,gg :call MyGit("new post:")
>>
>>
>>
>> what's the problem?
>>
> nn, or :nnoremap, is a mapping from normal mode. So, all characters on the right-hand side will be executed by Vim as if you typed them from normal mode.
>
> In other words, Vim will enter the command line when it "types" the ':' character, inserts the rest of the line on the command line, and then...does nothing, because there is nothing else in the mapping for it to do.
>
> Follow up your mapping with "<CR>" or "<Enter>" to tell Vim to send the enter key for you.
>
> I.e. you mapping should be:
>
> nn ,gg :call MyGit("new post:")<CR>
>
I just tested, no luck still...

//code:
function! MyGit(commitmsg)
let commitmsg=a:commitmsg
let GitCmd=":
\!git add -A .;
\!git commit -m " .
\commitmsg . ";" . "
\!git push origin master" .
\repeat("\<left>", 30)
exec GitCmd
endf
command! -nargs=? MyGit :call MyGit(<q-args>)
nn ,gg :call MyGit("new post:")<CR>

//result:
Error detected while processing function MyGit:
line 8:
E34: No previous command
Press ENTER or type command to continue

so that repeat thing still confuses me...

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment