Vim how to add a key binding that accepts input
I am new to vim but I am trying to create some C ++ environment.
I am using ctrl f (or ctrl-shift-f) to help me find the files. So I saw a plugin that I liked called pss.
I would like to replace ctrl-f with something that will accept input, but add its own parameters (like cpp for example). I was thinking about something like:
how can i make it right?
noremap <C-f>:Pss $1 *.cpp
source to share
Since you have command line editing capabilities, the commonly used approach simply creates an incomplete mapping. You can place the cursor at the edit location, for example:
:noremap <C-f> :Pss *.cpp<Left><Left><Left><Left><Left><Left>
After launching the display (via <C-f>
) you can insert a search pattern and then start the search via <CR>
.
Alternative
You can request input using a function input()
; its result can be inserted into the command line via :execute
:
:noremap <C-f> :execute 'Pss' input('Pattern: ') '*.cpp'<CR>
source to share