I want to extract information from file path and use it as part of substitute string, racked my mind, tried many times and only to found the follwing works
let spd = split(expand('%:p'),"/")
%s/to_be_replaced/\=spd[-2]/g
I want to merge the two commands into one
%s/to_be_replaced/\=split(expand('%:p',"/"))[-2]/g
but it doesn't work. Since I am working with multiple files in tab mode, the two commmands method is actually quite inconvenient. Moreover, it doesn't fulfill the requirement since
%s/to_be_replaced/some_string\=spd[-2]more_string/g
is also wrong. So I am wondering if there is a solution or a quicker way to do it?