I have a self-extracting "archive" generated by Makeself tool, which is essentially a shell script with a large binary blob in inside. What I want is to view only text part of the file, while hiding the binary part completely (possibly abbreviating it to one line).

If there is a way to speed up the process of opening such file by preventing vim from reading binary portion, that's even better. Currently, I have to use less for viewing such files, because vim just takes too long to load.

  • Maybe one possibility would be to add comments with fold markers around the binary part (# {{{ and # }}}) and a modeline as the first line of your file # vim fdm:marker this way vim will fold this part. The problem is that I don't know makeself and don't know if you can make it add these lines. – statox Sep 13 '17 at 11:07
  • @statox I also don't know Makeself, and I wouldn't make such script in the first place. The point is, I want a solution that will work with files I receive from other people. Possibly, a way to make vim discard everything after first binary character, although not ideal, would probably be sufficient. – Thunderbeef Sep 13 '17 at 11:38
  • Oh I didn't understand that you wasn't the one generating the file. Maybe you can set foldmethod to expr and use fold-expr to match non ascii characters. – statox Sep 13 '17 at 13:52
  • @statox Thanks for the advice. I'll look into that. Some research is in order, though. fold-expr syntax currently looks like a black magic to me. – Thunderbeef Sep 18 '17 at 11:57
  • :h fold-expr gives good explainations: the expression you give to foldexpr is evaluated for each line of the file (that you can reference to v:lnum) and should return an integer (positive or negative) or some other strings that are explained in the doc. Depending on what is return, vim will fold or not the line. This vimcast should also help you. If I find some free time I'll see if I can write one for you. – statox Sep 18 '17 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.