Call the vimscript function, which has a range using local variables, starting with the vimscript function

Here is an example I'm working with. It is intended to add a template to a file, and then comment out these lines that are simply read using the vCom BlockComment plugin function. The goal is to mark the line number before I read from the file and after I finish reading from the file so that I can comment on the range of lines just inserted. However, I have time to figure out which syntax should point to this range. The commented line below is my attempt to call a function with a given range using variables. The commented part has a syntax error if I provide a range of hard code, as shown below, the script works below. How then do we put our range in a variable?

function! AddBoilerPlate() let s:beginLine = line(".") r /Users/danieljbrieckjr/myBolierPlate.txt exe "normal! joDate Created: " . strftime("%B %d, %Y") exe "normal! oLast Modified: " . strftime("%B %d, %Y") let s:endLine = line(".") "-------------------------------------------------- " s:beginLine, s:endLine call Comment() "-------------------------------------------------- 1,3 call Comment() endfunction 
+4
source share
1 answer

In this situation, you can prepare a line containing the target command, and then use :execute to run,

 :exe s:beginLine.','.s:endLine 'call Comment()' 
+11
source

Source: https://habr.com/ru/post/1392315/


All Articles