Is there a script that allows me to edit multiple files as if they were a single file in VIM?

I prefer to edit in only one large file, and not in many independent files, but due to language restrictions, version control and the preferences of teammates, I need to output to many files.

What I'm looking for will process all the files in the source directory and generate one file for editing in VIM with special seperator markers. When saving, it will save the changes to the correct file (s) ideally in a smart way, based only on the changes made.

Is there something similar?

+4
source share
3 answers

ball

Well, you can use shar(1) , but it puts an X in front of every line that you are likely to find annoying. (Shar came with my Mac, but on my Linux systems you need to add a package.)

Shar is a simple, short shell script itself, so you can easily modify it to work without X.

You can try copying / usr / bin / shar to / tmp and apply this diff with patch(1) .

 --- /usr/bin/shar 2009-07-13 22:26:18.000000000 -0700 +++ /tmp/shar2 2010-12-24 19:05:34.000000000 -0800 @@ -65,8 +65,8 @@ echo "mkdir -p $i > /dev/null 2>&1" else echo "echo x - $i" - echo "sed 's/^X//' >$i << 'END-of-$i'" - sed 's/^/X/' $i + echo "cat >$i << 'END-of-$i'" + cat $i echo "END-of-$i" fi done 
+2
source

It reminds me of the vimballs format. However, this meant expanding the files into the user runtime directory.

In other words, you can list all the files you want to join and apply :MkVimBall (here is an example ). Then, to extract, you will need to momentarily (that is, save and restore its value after extraction) install &runtimepath in the root directory of your project before extraction with :so % .

You will also have to play with various options like &filetype etc.

This is a dirty hack, but well ... he has to do the job.

+1
source

Instead of dumping several files into one, processing this one and then sharing the material again, you can use bufdo or windo to repeat the command in all open buffers: open the buffers that need to be processed, then execute bufdo and it will work for each open file: http://vimdoc.sourceforge.net/htmldoc/windows.html#list-repeat

+1
source

Source: https://habr.com/ru/post/1333317/


All Articles