I am detecting malwares in PDF files for which I need their source codes too. I want to save the source code in some text file so that I can write a code to scan through all of them to detect patterns. How can I save what I see on Vim (source code)?

  • 3
    Are you asking "how do I save a file"? If not, please clarify. – user859 Jan 17 '18 at 10:42
  • Is the file being processed prior to entering Vim? It sounds like you're just opening a PDF in a text editor, which works (to an extent) because PDF is a plaintext format at its core... just the individual object streams are typically binary (if nothing else, compressed with Flate). It sounds like 'saving the source' is really just 'copying the file', unless of course something is handling it aside from Vim. – brhfl Aug 13 '18 at 20:46

I would open another tab "Vertical split"/ "Horizontal Split" with :vs and copy paste the parts of the code that I want with "Visual selector" v and then y to copy.

Then got to the next tab where you can browse to destination file with :e .

And finally, paste to the other file with p and save & close it :wq.

I'm sure there are other options to do this but if you're in a hurry then this will do it!

  • Why wouldn't you just select what you want with v and type :w newfile.txt (which will be converted to :'<,'>w newfile.txt) ? – ChatterOne Oct 12 '18 at 8:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.