Monday, November 25, 2013

Re: From function: directing error from external command to window and open files in specific windows of current tab

2013-11-25 16:49, Ben Fritz skrev:
> On Monday, November 25, 2013 5:40:15 AM UTC-6, BPJ wrote:
>> I need help with the following. I've googled for half an hour
>>
>> but don't seem to be able to formulate the questions
>> correctly.
>>
>> As usual it's probably in the help but I don't know where
>> to look!
>>
>>
>
> In the future please start two separate threads if you have two
> questions.

Sorry! They were linked in my mind because they happen in the
same function -- indeed the output from the one is used as the
file basename for the other. I'll try to remember that what seems
connected to me not necessarily is so out of my context!

>
>>
>> * How to call an external script from inside a function
>> without
[snip]
>
> The system() function will return (as a string) the output of
> an external command without modifying any text in buffers.
>
> After system() runs the error code returned is in
> v:shell_error.

No way to get stderr?

>> * How to open a specific file in a specific window of the
[snip]
>
> Each window inside Vim is assigned a number. Window numbers
> start at 1 in the topmost leftmost window and always increase
> as you go down or right. So in this example 'a' will have
> window number 1, b will have 2, and c will have 3.

I had a thinko wrt two horizontally split windows to the right
of a vertical split. It's clear to me now that top right
necessarily comes before bottom right. Yuck, my tabs look like
comic-book pages sometimes...

>
> To open a specific file in a specific window, you will need 2
> or 3 steps:
>
> 1. Jump to the desired window
> 2. Open the file
> 3. [optional] jump back to the previous window
>
> For example, to edit "myfile.txt" in window 3 and then return
> to the previous window:
>
> 3wincmd w | e myfile.txt | wincmd p
>
> You can build such a string with a few :execute commands if you
> need to calculate file names or window numbers from variables.
>

All clear now, except for how to capture stderr. Thanks!

/bpj

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