I was looking at this question on Unix & Linux Stack Exchange, and I thought I could write an answer for it using Vim.
I ran the following for a quick test, and was surprised to find it didn't seem to do anything. I was expecting it to replace the first number on the first line with one less than the number of lines in the buffer.
:execute '1s/^[0-9]\+/' . line('$')-1 . '/'
Here is the text I had in the buffer at the time:
5 10
sample_1 gaatatccga
sample_2 gaatatccga
sample_3 gaatatcgca
Why didn't the :execute
command shown above replace the 5
with a 3
as intended?