How does vim write functions that can interact on the command line?

  question, vim

nnoremap <leader>c :Ack '^class ' <c-r>=&path<cr><home><right><right><right><right><right><right><right><right><right><right><right><right>

Ack is used to search pattern under the &path path.

In this mapn*<right>Ugly dead, how can we optimize it?

With the help of the community, I put the final method below:

" help input
 
 function!  AckClass()
 let l:classPattern = input('Pattern: ')
 execute " Ack '^class " . l:classPattern . "' " . &path
 endfunction
 
 command!  AckClass call AckClass()

I don’t know to what extent you want to interact

function!  ChangeFileencoding()
 let encodings = ['GB18030', 'GBK', 'cp936', 'utf-8', 'big5', "latin1", "euc-kr", "euc-jp", "ucs-bom", "shift-jis"]
 let prompt_encs = []
 let index = 0
 while index < len(encodings)
 call add(prompt_encs, index.'. '.encodings[index])
 let index = index + 1
 endwhile
 let choice = inputlist(prompt_encs)
 if choice >= 0 && choice < len(encodings)
 execute 'e ++enc='.encodings[choice].' %:p'
 endif
 endf

This is my vimrc’s function of changing codes to open files. It will present a list of options for your reference.