10 years ago
Press <Key> to remove everything from the command-line except the :command itself followed by a <Space>.
<Key>
:command
<Space>
cnoremap <Key> <C-\>esplit(getcmdline(), " ")[0]<CR><Space>
Konfekt 10 years ago ✎
Thank you for sharing your useful snippets. This one combines well with http://vimrcfu.com/snippet/38 whith <key> = <s-tab>.
<key> = <s-tab>
How about appending \<c-e> to enure that <space> is inserted after the command?
\<c-e>
<space>
I am now using
function! CmdLineShiftTab() if getcmdtype() == "/" return "\<CR>/\<C-r>/\<CR>?\<C-r>/" elseif getcmdtype() == "?" return "\<CR>?\<C-r>/\<CR>/\<C-r>/" elseif wildmenumode() return "\<S-Tab>" else return "\<C-\>esplit(getcmdline(), ' ')[0]\<CR>\<c-e>\<Space>" endif endfunction
Konfekt 10 years ago ✎
Thank you for sharing your useful snippets. This one combines well with http://vimrcfu.com/snippet/38 whith
<key> = <s-tab>
.How about appending
\<c-e>
to enure that<space>
is inserted after the command?I am now using
function! CmdLineShiftTab() if getcmdtype() == "/" return "\<CR>/\<C-r>/\<CR>?\<C-r>/" elseif getcmdtype() == "?" return "\<CR>?\<C-r>/\<CR>/\<C-r>/" elseif wildmenumode() return "\<S-Tab>" else return "\<C-\>esplit(getcmdline(), ' ')[0]\<CR>\<c-e>\<Space>" endif endfunction