I have the following function that I'm calling to insert blank lines under the cursor:
function InsertBlankLine()
call LogOutput('*** START ***', "DEBUG", {'line': expand('<sflnum>'), 'func': expand('<sfile>')[9:]})
" a: args will give us the following by default: -- see `:h: a:var`
" '0': '000': 'firstline': 109, 'lastline': 108
" '0' is the number of extra arguments, '000' is the list of those extra args
let data = a:
call LogOutput("Data: " . string(data), "DEBUG", {'line': expand('<sflnum>'), 'func': expand('<sfile>')[9:]})
" Access a dict value get(dict, 'value')
let first_line = get(a:, 'firstline')
" Insert a new line
call LogOutput('Executing normal o', "DEBUG", {'line': expand('<sflnum>'), 'func': expand('<sfile>')[9:]})
execute "normal! o"
" Go back to the first line
let cmd = printf("normal! %sG", first_line)
call LogOutput('Executing cmd: ' . cmd, "DEBUG", {'line': expand('<sflnum>'), 'func': expand('<sfile>')[9:]})
execute cmd
endfunction
And I can call it like this with a shortcut:
nnoremap T :call InsertBlankLine()<CR>
So that I can type in 10T
and it will insert ten blank lines. This all works. However, it spits out a lot of input which I want to suppress using silent
. However, I'm not sure how to pass :silent
to the function as it will usually start with a number. For example, if I type in 10T
, this is the command it runs:
:.,.+9call InsertBlankLine()
So how would I get that to execute silently (without removing the LogOutput's ?
:
in:call
... – filbranden♦ Jun 15 '20 at 3:54:.,.+9call InsertBlankLine()
. However, when I try and add asilent
to the cmd it's erring. – David542 Jun 15 '20 at 4:51:.,.+9silent call ...
(shouldn't work) and:silent .,.+9call ...
(I'm guessing this one works?) In any case, please edit your question to match what you actually tried to do. – filbranden♦ Jun 15 '20 at 4:55