I was trying out "continuing macros despite error" as mentioned here. My test code looks like this
this is line number 1
this is line 2
this is line 3
this is line 4
this is line 5
this is line 6
this is line 7
this is word 8
this is line 9
this is line 10
this is line 11
where I have already recorded below macro on the first line. This macro basically appends the text " number" after the first "e" find result and then goes and sits at the start of the the next line. (^[
is the Escape key.)
fea number^[j0
As per the above link, I modified this to
:try|norm fea number^[j0|catch||endtry^M
I want to run this macro to the end of the file, where it will not find the "e" character on line 8 but still continue due to the :try
command.
The :try
function works correctly, but overall the edited macro does not work as intended (it does something extra). On checking with :registers
the same macro contents look like this
:try|norm fea number^[j0|catch||endtry^M^J
The additional and unexpected ^J
makes the 2 lines join (not what I intend). Basically this, if ran on line 2 -
this is line number 1
this is line number 2 this is line 3
this is line 4
Where did this ^J
come from ? What am I doing wrong? And how can I make this macro work as intended?
I tried this in git bash as well as in gvim (both on windows).
Additionally :set ff?
results in fileformat=unix
.
This looks like a perfect use case for
:help global
: