vim - How to give variable arguments to `makeprg` -
i have build script "maker", intend set makeprg. script takes 2 arguments: flag_verbose
, flag_install
, former suggests whether give verbose output(for each program) later causes installation if build successful.
now wish set few key mappings like: <f7-(a/d/j/z/i)> :make <return> :copen
here want carry argument maker script. flag_verbose
, flag_install
consist of single character from(a[apt}/d[x]/j[avac]/z[all]) , 'i[nstall]' respectively.
so want give different arguments script depending on <fn-x>
keystrokes, x being different flags. can set such functionality in vimrc or vimscript? if , how ?
first, there's no <f7-a>
notation, , cannot define mapping gets triggered pressing f7 , a simultaneously. can map sequence, written <f7>a
.
so, define following set of mappings:
nnoremap <f7>a :make a<cr>:copen<cr> nnoremap <f7>d :make d<cr>:copen<cr> ...
this can simplified via metaprogramming:
for s:arg in ['a', 'd', 'j', 'z', 'i'] execute printf('nnoremap <f7>%s :make a<cr>:copen<cr>', s:arg) endfor
but instead opt solution, prepares incomplete command-line , positions cursor @ position arguments placed. this, have single mapping, , have possibility pass no or multiple arguments. downside have press enter launch command:
noremap <f7> :execute 'make '<bar>copen'<left><left><left><left><left><left><left><left>
Comments
Post a Comment