I have 2 commands that work all right to add line numbers to whole file or selection and to change those line numbers to create 1]
format:
command -range=% Addln2 <line1>,<line2>!cat -n
command -range=% Addln3 <line1>,<line2>s/\v\s+(\d+)\s+/\1] /g
However, I am not able to combine them to one command. I tried:
command -range=% Addln2 <line1>,<line2>!cat -n | s/\v\s+(\d+)\s+/\1] /g
but it produces error.
Using sed also does not work:
command -range=% Addln2 <line1>,<line2>!cat -n | sed 's/\v\s+(\d+)\s+/\1] /g'
I also tried to put them together in a function:
function Addlnfn() range
a:firstline,a:lastline !cat -n
a:lastline,a:firstline s/\v\s+(\d+)\s+/\1] /g
endfunction
command -range=% Addlnfn <line1>,<line2>call Addlnfn()
But this also produces an error: Missing endfunction
Where is the problem and how can this be solved? Thanks.