Excerpts from Benjamin R. Haskell's message of Thu Jun 28 19:35:19 +0200 2012:
> Unfortunately, spellbadword() can change the cursor position.
So? use
let save_cursor = getpos(".")
MoveTheCursorAround
call setpos('.', save_cursor)
to set cursor to old position. Not perfect - but fine.
A second way is use sp to create a new window, move cursor there, then
:q the split window again.
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
Thursday, June 28, 2012
Re: g_ different from :normal! g_
On 06/28/12 15:32, rockybalboa4 wrote:
> Is there any rationale behind the fact that
> dg_
> yields different results than
> d:normal! g_
> ? The latter does not reach the last character on the line. Is it documented? Shouldn't it be documented? Is it a bug?
I suspect it's a bug. From some quick testing
:norm dg_
works, and
dg:norm _
chokes at the ":", returning to normal mode.
It's been a long time since I played around with "g_", as I've never
found a time I wanted to keep trailing space.
-tim
--
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
> Is there any rationale behind the fact that
> dg_
> yields different results than
> d:normal! g_
> ? The latter does not reach the last character on the line. Is it documented? Shouldn't it be documented? Is it a bug?
I suspect it's a bug. From some quick testing
:norm dg_
works, and
dg:norm _
chokes at the ":", returning to normal mode.
It's been a long time since I played around with "g_", as I've never
found a time I wanted to keep trailing space.
-tim
--
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
Re: vim: use external program, but direct output to a new vsplitted buffer
On 2012-06-28, ping wrote:
> 2) :'<,>'w !ext-prog
> I found this syntax is interesting.
> it take seleted text as input, but just print the output to the
> screen, without overiding the selected text. which seems good.
>
> so using another tip I learned from a previous thread, how about this:
>
> "redirect output to reg z
> :redir @z
> "take seleted text as input, output to screen
> :'<,'> !asciidoc ...
> "end redirection
> :redir END
> "open a vsplit win
> :vsp
> "paste content of reg z
> "zp
>
> surprisingly I got nothing here.
:redir redirects the output of Vim commands, not shell commands.
> currently I'm just using:
> :'<,'>!ext-prog
> yank the output (which overide my original texts as input)
> u to recover my text back
> open another window and paste
If I were doing this, I would do something like this:
:'<,'>w !ext-prog > /tmp/mytmpfile
:new
:r /tmp/mytmpfile
:!rm /tmp/mytmpfile
or
:'<,'>w !ext-prog > /tmp/mytmpfile
:split /tmp/mytmpfile
I'll leave the generation of the temporary file name to you. Some
people are really paranoid about it. If you're going to have more
than one such temporary file open at a time, use tempname().
Regards,
Gary
--
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
> 2) :'<,>'w !ext-prog
> I found this syntax is interesting.
> it take seleted text as input, but just print the output to the
> screen, without overiding the selected text. which seems good.
>
> so using another tip I learned from a previous thread, how about this:
>
> "redirect output to reg z
> :redir @z
> "take seleted text as input, output to screen
> :'<,'> !asciidoc ...
> "end redirection
> :redir END
> "open a vsplit win
> :vsp
> "paste content of reg z
> "zp
>
> surprisingly I got nothing here.
:redir redirects the output of Vim commands, not shell commands.
> currently I'm just using:
> :'<,'>!ext-prog
> yank the output (which overide my original texts as input)
> u to recover my text back
> open another window and paste
If I were doing this, I would do something like this:
:'<,'>w !ext-prog > /tmp/mytmpfile
:new
:r /tmp/mytmpfile
:!rm /tmp/mytmpfile
or
:'<,'>w !ext-prog > /tmp/mytmpfile
:split /tmp/mytmpfile
I'll leave the generation of the temporary file name to you. Some
people are really paranoid about it. If you're going to have more
than one such temporary file open at a time, use tempname().
Regards,
Gary
--
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
g_ different from :normal! g_
Is there any rationale behind the fact that
dg_
yields different results than
d:normal! g_
? The latter does not reach the last character on the line. Is it documented? Shouldn't it be documented? Is it a bug?
--
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
dg_
yields different results than
d:normal! g_
? The latter does not reach the last character on the line. Is it documented? Shouldn't it be documented? Is it a bug?
--
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
Re: vim: use external program, but direct output to a new vsplitted buffer
thanks Ben, for the solutions.
looks like the default behavior is , if you selected a range of text as
the input, then the output from external prog will overide the input
texts...
1) to summarize as a learning excercise
http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window
this looks good when no need use range of text as input
2) :'<,>'w !ext-prog
I found this syntax is interesting.
it take seleted text as input, but just print the output to the screen,
without overiding the selected text. which seems good.
so using another tip I learned from a previous thread, how about this:
"redirect output to reg z
:redir @z
"take seleted text as input, output to screen
:'<,'> !asciidoc ...
"end redirection
:redir END
"open a vsplit win
:vsp
"paste content of reg z
"zp
surprisingly I got nothing here.
3) yes asciidoc has its way to define an output filename, but my again
that's not what I want (I want the def a similar behavior like :TOhtml)
but it's not big deal. either way I can done my work, just wonder what's
the best options here.
currently I'm just using:
:'<,'>!ext-prog
yank the output (which overide my original texts as input)
u to recover my text back
open another window and paste
regards
ping
On 06/28/2012 11:20 AM, Ben Fritz wrote:
>
> I first thought of this:
>
> http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window
>
> But it looks like it won't work for your purposes, because you want to use lines in the current buffer as input to the external command.
>
> You could probably use :'<,'>w !asciidoc ...
>
> But then you'll need to put that output into a new buffer somehow.
>
> Probably you can :'<,'>w !asciidoc ... > somefile.html
>
> and then load somefile.html into a new buffer.
>
> Or maybe, asciidoc has an option to write to a file?
>
> Anyway, the relevant help is :help :w_c
>
--
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
looks like the default behavior is , if you selected a range of text as
the input, then the output from external prog will overide the input
texts...
1) to summarize as a learning excercise
http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window
this looks good when no need use range of text as input
2) :'<,>'w !ext-prog
I found this syntax is interesting.
it take seleted text as input, but just print the output to the screen,
without overiding the selected text. which seems good.
so using another tip I learned from a previous thread, how about this:
"redirect output to reg z
:redir @z
"take seleted text as input, output to screen
:'<,'> !asciidoc ...
"end redirection
:redir END
"open a vsplit win
:vsp
"paste content of reg z
"zp
surprisingly I got nothing here.
3) yes asciidoc has its way to define an output filename, but my again
that's not what I want (I want the def a similar behavior like :TOhtml)
but it's not big deal. either way I can done my work, just wonder what's
the best options here.
currently I'm just using:
:'<,'>!ext-prog
yank the output (which overide my original texts as input)
u to recover my text back
open another window and paste
regards
ping
On 06/28/2012 11:20 AM, Ben Fritz wrote:
>
> I first thought of this:
>
> http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window
>
> But it looks like it won't work for your purposes, because you want to use lines in the current buffer as input to the external command.
>
> You could probably use :'<,'>w !asciidoc ...
>
> But then you'll need to put that output into a new buffer somehow.
>
> Probably you can :'<,'>w !asciidoc ... > somefile.html
>
> and then load somefile.html into a new buffer.
>
> Or maybe, asciidoc has an option to write to a file?
>
> Anyway, the relevant help is :help :w_c
>
--
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
Re: vim: use external program, but direct output to a new vsplitted buffer
looks like option1 (which I was currently using before sending
consulting email out) is simple for me...
thanks!
On 06/28/2012 11:46 AM, Marc Weber wrote:
> There are many ways to do what you're asking for.
>
> 1) Don't bother because u = undo is that fast and copy the text manually
> to a new buffer (c-w s then paste).
>
> 2) If you really need it that often that you want to write a script for
> this is most simple:
>
> map \doit :%! external-app > foo.txt<cr>u<c-w>s:r foo.txt<cr>
> note that u undoes replacing the lines
>
> now you may want to use a tempfile instead of foo.txt ...
>
> Like this you can use <line1> and <line2> or such see :h command etc and
> use system (which accepts input) which you can get by :h getline()
> and join by :h join() (but \r\n may be replaced by \n then
> thus byte count may differ)..
>
> You can then paste the output of system to the new buffer by
> puts=split(system("command", join(getline(lnum1,lnum2))))
> or by using call append() or the like.
>
> If you don't want to bother about all this lnum1 lnum2 stuff you can
> also just yank to register by y and access that which would be shortest:
>
> map \doit y<c-w>s:call append(split(system('command',@"),"\n"))<cr>
>
> or such - but it pollutes your yank registers .. (you could use other
> registers instead)
>
> 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
consulting email out) is simple for me...
thanks!
On 06/28/2012 11:46 AM, Marc Weber wrote:
> There are many ways to do what you're asking for.
>
> 1) Don't bother because u = undo is that fast and copy the text manually
> to a new buffer (c-w s then paste).
>
> 2) If you really need it that often that you want to write a script for
> this is most simple:
>
> map \doit :%! external-app > foo.txt<cr>u<c-w>s:r foo.txt<cr>
> note that u undoes replacing the lines
>
> now you may want to use a tempfile instead of foo.txt ...
>
> Like this you can use <line1> and <line2> or such see :h command etc and
> use system (which accepts input) which you can get by :h getline()
> and join by :h join() (but \r\n may be replaced by \n then
> thus byte count may differ)..
>
> You can then paste the output of system to the new buffer by
> puts=split(system("command", join(getline(lnum1,lnum2))))
> or by using call append() or the like.
>
> If you don't want to bother about all this lnum1 lnum2 stuff you can
> also just yank to register by y and access that which would be shortest:
>
> map \doit y<c-w>s:call append(split(system('command',@"),"\n"))<cr>
>
> or such - but it pollutes your yank registers .. (you could use other
> registers instead)
>
> 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
Re: vim: use external program, but direct output to a new vsplitted buffer
this is nice. thanks!
regards
ping
On 06/28/2012 01:44 PM, Charles Campbell wrote:
> ping wrote:
>> experts:
>> this may be easy for experts but I'm still in beginners level...
>>
>> a common usage of the external program is to process texts in curr
>> buffer and put it back(to replace) the texts like a pipeline - which
>> is great in most circumstances.
>>
>> but sometime I don't want to modify my text but rather redirect the
>> output to another buffer -- pretty much like what TOhtml does.
>>
>> particularly I want to visual select a range of text and call the
>> ext-prog, then got the result in a new splitted buffer.
>>
>> eg. I want to visual select texts and then:
>>
>> :'<,'>!asciidoc -a toc -a toclevels=3 -
>>
>> to convert the texts into html on stdout.
>>
>> how to achieve that?
>>
> Perhaps RunView will be of help, although I don't have asciidoc
> available to test the specific case.
>
> RunView: http://www.drchip.org/astronaut/vim/index.html#RUNVIEW
>
>
> let g:runview_filtcmd= "asciidoc -a toc -a toclevels=3 -"
>
> Then
>
> :[range]RunView
>
> Regards,
> Chip Campbell
>
--
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
regards
ping
On 06/28/2012 01:44 PM, Charles Campbell wrote:
> ping wrote:
>> experts:
>> this may be easy for experts but I'm still in beginners level...
>>
>> a common usage of the external program is to process texts in curr
>> buffer and put it back(to replace) the texts like a pipeline - which
>> is great in most circumstances.
>>
>> but sometime I don't want to modify my text but rather redirect the
>> output to another buffer -- pretty much like what TOhtml does.
>>
>> particularly I want to visual select a range of text and call the
>> ext-prog, then got the result in a new splitted buffer.
>>
>> eg. I want to visual select texts and then:
>>
>> :'<,'>!asciidoc -a toc -a toclevels=3 -
>>
>> to convert the texts into html on stdout.
>>
>> how to achieve that?
>>
> Perhaps RunView will be of help, although I don't have asciidoc
> available to test the specific case.
>
> RunView: http://www.drchip.org/astronaut/vim/index.html#RUNVIEW
>
>
> let g:runview_filtcmd= "asciidoc -a toc -a toclevels=3 -"
>
> Then
>
> :[range]RunView
>
> Regards,
> Chip Campbell
>
--
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
Subscribe to:
Posts (Atom)