I have two text files including steps, one is the main-file which has the entire steps and the other one is a sub-file has only part of steps. As follows.
[main-file] SeqMain.txt
0001 K1G554 1 1 21-56 3 C- 2 1 0 0 0 D001
0002 K1H060 1 3 11-46 1 21-56 3 0 0 P 0
0003 K1G049 5 1 23-56 4 C- 4 1 0 0 0 D002
0004 K1H520 5 3 27-36 4 23-56 4 0 0 P 0
0005 K1G004 15 1 29-56 3 C- 6 1 0 0 0 D003
[sub-file] SeqSub.txt
001 000x K1G554 C- 2 1 AY-29 1
002 000y K1G049 C- 4 1 AY-19 1
003 000z K1G004 C- 6 1 AY-09 1
And I always have to modify the main-file to change the sequence of steps many times. Every time the main file was changed, the step numbers in the sub-file needs to be updated too.
Here is how I edit them by using VIM:
1.I sort the main-file by the column 46 :sort/\%46
, put the cursor at row3-column1 and blockwisely visual select ctrl-v
the row3-column1 to row6-column4 and yank y
0002 K1H060 1 3 11-46 1 21-56 3 0 0 P 0
0004 K1H520 5 3 27-36 4 23-56 4 0 0 P 0
0001 K1G554 1 1 21-56 3 C- 2 1 0 0 0 D001
0003 K1G049 5 1 23-56 4 C- 4 1 0 0 0 D002
0005 K1G004 15 1 29-56 3 C- 6 1 0 0 0 D003
0001
0003
0005
2.Then I open the sub-file vsplit SeqSub.txt
, put the cursor at row1-column4, and paste what I just yanked on it 1vp
.
001 0001 K1G554 C- 2 1 AY-29 1
002 0002 K1G049 C- 4 1 AY-19 1
003 0003 K1G004 C- 6 1 AY-09 1
I tried to write the steps above into a syntax file in vimscript or recording them q
that I can source the script to complete the steps. The function execute normal! ...
can do the same editting in normal mode.
But in visual mode it did't work.
Does there any function for blockwise visual selection in vimscript? Or does anyone have a better solution to compare and update both files?
norm! ^V^Vjjllly
(^V^V
meaning to enter actual Ctrl-V twice to enter visual block select upon execution) that makes me think it has to be the second in which case I need clarification.qq
). There you should just be able to do things normally while recording. However if you wanted to edit the "recording" then to insert a visual block select command into the string you'd have to do the double Ctrl-V. Is this the information you're looking for? If so I can write an answer and explain what the double Ctrl-V is for. For mappings you'd also use it.\<C-V>
instead (i.e. mappings). There may actually already be an answer that addresses these particular topics. Did you search for visual block?join -1 x -2 x -o 2.1,1.1,2.3,2.4,2.5,2.6,2.7,2.8 ... etc