write to command0line prompt

25 views
Skip to first unread message

Renato Fabbri

unread,
Feb 18, 2018, 4:05:55 PM2/18/18
to vim_use
:normal :ls
does not leave the user with the cursor at the command-line, e.g. in:
:ls

Is there a way to write a function or is there a command I might use to
leave the user with a given string in the command-line?

Best,

Tim Chase

unread,
Feb 18, 2018, 4:09:10 PM2/18/18
to vim...@googlegroups.com
A mapping can leave you at the prompt if you don't append "<cr>" to
it:

:nnoremap <f2> :ls

Without knowing the context and what you're hoping to do with it,
it's hard to give much more detail.

-tim


Renato Fabbri

unread,
Feb 18, 2018, 5:08:44 PM2/18/18
to vim_use

Some context...

I have these mappings:
nnoremap ^[FF :Split echo globpath('/home/renato/repos/', "**/rdf*")
nnoremap ^[Ff :Split echo globpath(&rtp, "*/ttm*")
nnoremap ^[Fa :Split echo globpath(&rtp, "*/ttm*")<CR>
nnoremap ^[FA :Split echo globpath(&rtp, "**/pack/**")<CR>
(^[ stands for Alt here, achieved using <C-V>.)

I want the following mapping:
" nnoremap ^[Ff :Split echo globpath(&rtp, '"**/' . expand("<cword>") . "*")

which does not work because Vim considers the whole expression as a string
and does note evaluate expand().

To make this work, I made a function with variations such as:

fu! SearchFilenameRTP()
let a = expand("<cword>")
let b = '**/' . l:a . '*'
let c = ':Split echo globpath(&rtp, "' . l:b . '")'
normal l:c
endfu

but I can't get the string in l:c into the command-line.

-renato


>
> -tim

Renato Fabbri

unread,
Feb 21, 2018, 1:03:20 AM2/21/18
to vim...@googlegroups.com


:'-|


may one assume that is is not possible to leave the cursor
in the command line with some text written if not through a mapping?

Best,
rf



>
> -tim

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/fZowH6oqwYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Renato Fabbri
GNU/Linux User #479299

Christian Brabandt

unread,
Feb 21, 2018, 2:53:40 AM2/21/18
to vim...@googlegroups.com

On Mi, 21 Feb 2018, Renato Fabbri wrote:

>
>
> :'-|
>
>
> may one assume that is is not possible to leave the cursor
> in the command line with some text written if not through a mapping?

:call feedkeys(':foobar', 'n')

Best,
Christian

Renato Fabbri

unread,
Feb 22, 2018, 2:24:05 AM2/22/18
to vim...@googlegroups.com
ow that is something I eagerly looked... Today I stumbled on some functions
to change the position of the cursor on the command line, and remembered
your answer many times.

Thank you very much.

(I have been avoiding thank you messages for they might be regarded
verbose with little to add to que discussion.
Are there any guidelines for this list?
Answers here have been most useful.
Thanks again.
renato)
 

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/fZowH6oqwYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages