> Dear all,
> I want to create a command that will insert comment mark, for instance
> '#', space, date and time on the next line after current, but AFAICS
> there is no way to put insert commands like o in command. The most
> obvious way - use mapping, but it is preferable to use command feature
You don't want to use the o command, because that leaves you in insert
mode. You're looking for the append() function:
command TimedComment :call append(line('.'), '# '.strftime('%Y-%m-%d %H:%M:%S'))
Another common idiom, if the comment you want to insert gets complex, is
to create a function, then call the function from a command.
E.g. Convert2HTML() is a function that converts a specified range to
HTML in a new buffer:
command -range=% TOhtml :call Convert2HTML(<line1>, <line2>)
--
Best,
Ben
--
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:
Post a Comment