:h *print*()<c-d>
and you'll see printf(). Hit <tab><cr> and be happy.
> 2) I know there is one command named 'append', but it is not convenience to
> me. so where do I find others?
"But I don't like it - not telling you about what I would prefer" - How
do you expect anybody being able to help you ?
Either use loop or put or python scripting interface which has buffer
objects. or <c-r>=[1,2,3]<cr> (insert mode)..
Or <c-r>=myfun(input('enter something'))<cr>
Without knowing what you want to do its impossible to assist.
Eventually you're just looking for a snippet engine such as snipmate?
Marc Weber
--
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
<C-R>=printf('%s', 'foo')
And upon hitting enter, "foo" will appear after the cursor in the
current buffer. Is that the sort of thing you're trying to do?
Note that "<C-R>" is a literal Ctrl-R in the above example.
Excerpts from Steve liu's message of Tue Nov 08 12:51:11 +0100 2011:
> 1) yeah, I've really used help. But result is printed to status line not on
> the text.
Tell people about what you've tried in your email. So your problem is
not printf, but "How to get text into the buffer" (which is something I
had to guess in the last mail)
> what i want to do is to use vim internal function to print sth. on the
> text, editing.
What. Think about Vim being human and imagine Vim understanding the
English language. Then explain to vim what it should do.
Copy paste this text into your reply to this mail. Then you'll be
offered many nice ways to get your job done.
What do you mean by "print" ? printf outputs to stdout. Vim can't do
that. So its not clear to me what you mean by "print" in the context of
editing text with a text editor.
You usually
"insert text into a text file at particular position/line/..."
"replace text"
"insert templates you prepared so that you can reuse those lines many
times without retyping"
" .. "
But you don't "printf" - you printf, then insert somewhere.
It looks like you know how to printf. So the remaining issue is how can
I insert a string into a buffer? Now how to determine at which location
the text should be inserted? Why does append() not suffice?
.. Lot's of lots of questions.
> 2) though your word is kind of ...
That's a very bad habit: You should *always* make clear to what you're
referring to. The most common way is "bottom posting" which means:
1) delete everything you don't reply to.
2) put your text below the text you're referring to.
So if you say 'your word' I don't know what you're referring to.
There have been many "words" in my mail. And if you want to talk about
the way I express myself (I'm not a native speaker) "wording" would have
been a better word to say this.
> sorry for the second time. and thanks very much.
You're welcome. Never feel sorry. Try to improve your communication.
Each additional round trip just means that you've forgotten to add some
important information others need to know before they can help you.
Marc Weber
--
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
I asked you for phrasing the task using english words by purpose.
Does this describe what you're trying to do:
'pipe current line to external command
replacing current line by its output.'
?
Then .!printf "\s\n" 'hello world'
is close. Now all I have to tell you is that % is special: Vim
substitutes it by the buffer name. Thus escape it by \ and you're done
or use <c-r>=system('your shell command')<cr> in insert mode.
No reread your first mail. Try to understand why I wasn't able to sent
you this small solution the first time. We'll all perform better then.
Sincerly
Marc Weber
Marc Weber
--
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
alternative:
:put='abc'
caution:
:put="a" string "a but register "a!
redirect command and error to file
!command > file 2>&1
read file:
:r file
However then you can also use system, piping etc.
To understand the printf issue do:
:e NEW_FILE (Yes, I want you to open a buffer which is named NEW_FILE
sot hat you recognize this word easily)
Then try all of these:
:.!echo "%s\n" 'hello world'
:.!echo "%:ps\n" 'hello world'
:.!echo "\%s\n" 'hello world'
:.!echo "\s\n" 'hello world'
echo is just as printf. But it echoes arguments only - it doesn't
process them.
Now it you should understand what you're still doing wrong.
Marc Weber

Marc Weber
--
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
Actually, this will put into your buffer the last used expression (or
an empty line, if you haven't used the expression register yet), because
" terminates the command and indicates a comment following.
In command mode you need to escape the quotes.
regards,
Christian
Excerpts from Steve liu's message of Tue Nov 08 14:39:36 +0100 2011:
> then I turned into external command in vim. but it's not gonna work.
> then I turned into vim internal command, and found that I don't know it
Here I'm not sure I understand what you mean by internal vs external
command.
External command could be command line commands executed by shell.
internal commands are usually the :XXXX lines inside vim or .vim files.
> forgive me if I ... I'm not a native speaker. you're better than me. [?]
There is nothing I have to forgive. You didn't do anything wrong.
I'm trying to make you understand why I can't help you faster.
After waking up don't spend too much time. If you still don't get this
job done reply again - eventually also describing the patterns you're
talking about.
Also consider joining #vim on irc.freenode.net (any irc client will do)
Marc Weber
Marc Weber
--
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
It doesn't matter how you did it. It matters that you did it.
Congratulation!
Keep in Mind that VimL is nice for scripting tasks but doesn't scale
very well. Thus for larger projects consider interfacing with another
language such as python, perl, ruby, (there are countless others)
Marc Weber

Marc Weber
--
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
Quote a small (relevant) part of the message you are replying to,
and put your text underneath.
Delete text that is not needed to understand your reply
Note the footer below each message ("Do not top-post!").
John
Neither have I; and it should also be remembered that Vim is often
compiled without MzScheme, or without Python, etc., but never without
Vim-script capability � indeed, the latter cannot be left out at
compile-time. Parts of it can: for instance the stripped-down Vim
installed as "vi" on some Linux distros comes with (among others) no
syntax highlighting, no split windows and no arithmetic evaluation � but
it will still accept vim-script language (of a kind) in its vimrc.
Best regards,
Tony.
--
A chubby man with a white beard and a red suit will approach you soon.
Avoid him. He's a Commie.