Remove everything but the command name on the command-line

2 Points

Romain Lafourcade Romain Lafourcade

9 years ago

Press <Key> to remove everything from the command-line except the :command itself followed by a <Space>.

cnoremap <Key> <C-\>esplit(getcmdline(), " ")[0]<CR><Space>


Konfekt 9 years ago

Thank you for sharing your useful snippets. This one combines well with 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