1

I did my best to find the answer to this; my apologies if I missed it.

Some quick background: I'm looking at the protocol parsers in Bro, specifically those that have been created using BinPAC. In each folder I'm interested in, there are multiple files I want to open, using the naming convention {protocol-name}-protocol.pac, and {protocol-name}-analyzer.pac. The best way to view each protocol's files is side-by-side.

Now, what I want to do is have a separate tab open for each pair. That is, the first tab will have {protocol1}-protocol.pac in one window, and {protocol1}-analyzer.pac in an adjacent window, the second tab will have {protocol2}-protocol.pac in one window, and {protocol2}-analyzer.pac in an adjacent window, and so on.

I'm trying to figure out a way to do the above for all of the relevant folders in one command from the command line. I know how to open all the relevant files in separate tabs, or separate windows, but I can't figure out a way to combine these to get the behavior I want. I could do this manually i.e. open one pair, create a new tab and open another pair etc., but that's obnoxious and repetitive, so I'd much rather do it in one command if possible.

Anyone have any idea how to do this? Or if it's even possible?

7
  • Are you always using the exact same set of files? Commented Aug 22, 2014 at 21:29
  • I'm writing a protocol parser of my own, so I've added a new folder with a couple files, but other than that, yes. Why do you ask? Commented Aug 22, 2014 at 21:41
  • 2
    Well I was thinking that you could use sessions to save the layout of your splits, tabs, and files so that you would only have to open it once and then you could just open the session instead of opening each file over again. More on sessions here: stackoverflow.com/questions/1642611/… Commented Aug 22, 2014 at 21:52
  • I think either the session thing or writing vimscript to do this by checking filenames is the best way Commented Aug 22, 2014 at 22:01
  • I didn't know about sessions; that certainly looks like it'll solve my problem. Obviously, it'd be ideal to have a command to run, but in lieu of that, a session will work fine. Thanks! Commented Aug 22, 2014 at 23:34

1 Answer 1

0

It should be possible using --remote-tab option of vim

First start a vim server

     $ gvim --servername MYSERVER &

Now add your protocol files one by one to the vim server, while adding replace the -protocol in the file name to -analyzer and open it in vs[plit] to get the corresponding analyzer file.

     $ find  . -name \*.pac -exec gvim  --servername MYSERVER --remote-tab "+execute 'vs ' . substitute(expand('%:p'), '-protocol', '-analyzer', '')"  {} \;

Refer http://vimdoc.sourceforge.net/htmldoc/remote.html for more details.

Hope this is helpful

Sign up to request clarification or add additional context in comments.

1 Comment

The file name change is simple for me as i open '.c' file and its '.h'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.