2

I would like to open new tabs for each file matching an expression, each file in a new tab and as read only. I do not want to replace my current buffer, just append the new tabs.

This comes very close, but unfortunately it replaces any existing tabs:

command OpenLogs args X:\Path\ToLogs\*Log.txt | tab all | tabdo set readonly

Any ideas?

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271
roqvist
  • 131
  • 2
  • With "replaces any existing data" I assume you mean "Replaces all the existing tabs? See: How can I open multiple tabs at once? for an explanation on why this happens, and a way to fix it. – Martin Tournoij Jul 02 '15 at 11:38
  • Yeah that's right, any existing tab/tabs/buffers disappears running the above. I saw that for loop of yours earlier but was hoping it can be accomplished without writing a function. Perhaps that's not possible. – roqvist Jul 02 '15 at 11:54
  • You can put the code in a single line, if you want... for f in glob(..) | execute ... | setlocal readonly | endfor ... I don't see the problems with creating a function, though, as it's more readable. – Martin Tournoij Jul 02 '15 at 12:05
  • Thanks, I ended up using the entire function for readability. It's not too much code after all! – roqvist Jul 02 '15 at 12:08

1 Answers1

1

I ended up using Carpetsmoker's solution here: How can I open multiple tabs at once?, simply replacing

execute 'tabedit ' . l:c

with

execute 'tabedit ' . l:c . '| setlocal readonly'
roqvist
  • 131
  • 2