call altercmd#define('full', 'F-U-L-L') call altercmd#define('ab[br]', 'A-B-B-R') function! RecordTheCurrentCommandLine() let g:cmdline = getcmdline() return '' endfunction cnoremap {X} RecordTheCurrentCommandLine() function! Test(lhs, rhs) let g:cmdline = '' silent execute 'normal' ":".a:lhs."\{X}\" Expect g:cmdline ==# a:rhs endfunction describe 'altercmd#define' it 'replaces a built-in command' call Test('full', 'F-U-L-L') end it 'replaces all abbreviated names of a built-in command' call Test('ab', 'A-B-B-R') call Test('abb', 'A-B-B-R') call Test('abbr', 'A-B-B-R') end it 'supports ' silent edit 'test-A' call altercmd#define('', 'ctx', 'Axe') silent edit 'test-B' call altercmd#define('', 'ctx', 'Bow') silent edit 'test-C' call altercmd#define('', 'ctx', 'Club') silent edit 'test-A' call Test('full', 'F-U-L-L') call Test('ctx', 'Axe') silent edit 'test-B' call Test('full', 'F-U-L-L') call Test('ctx', 'Bow') silent edit 'test-C' call Test('full', 'F-U-L-L') call Test('ctx', 'Club') end end