fix viewdoc abbrevs and cabbrevs in general

Wed, 23 Aug 2017 01:14:56 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Wed, 23 Aug 2017 01:14:56 -0400
changeset 631
8e07c29f2672
parent 630
e5aec7abb8b5
child 632
9a87ce42aa3c

fix viewdoc abbrevs and cabbrevs in general

.vim/autoload/vimrc.vim file | annotate | diff | comparison | revisions
.vimrc file | annotate | diff | comparison | revisions
--- a/.vim/autoload/vimrc.vim
+++ b/.vim/autoload/vimrc.vim
@@ -1,3 +1,6 @@
+func! vimrc#CommandAlias(abbrev, expand) abort
+  execute printf('cnoreabbrev <expr> %s (getcmdtype()==":" && getcmdpos()==1) ? "%s" : "%s"', a:abbrev, a:expand, a:abbrev)
+endfunc
 
 func! vimrc#AutoFmtToggle() abort
   if &formatoptions =~ 'a'
--- a/.vimrc
+++ b/.vimrc
@@ -49,7 +49,8 @@ let s:filename   = expand('<sfile>')
   Plugin 'powerman/vim-plugin-viewdoc'
   Plugin 'powerman/vim-plugin-AnsiEsc'
 
-  let g:no_viewdoc_maps = 1
+  let g:no_viewdoc_maps   = 1
+  let g:no_viewdoc_abbrev = 1
 
   try
     execute 'source ' . s:filename . '.local-pre'
@@ -127,8 +128,18 @@ if exists("g:loaded_mucomplete")
   set shortmess+=c
 endif
 
-cabbr Q q
-cabbr W w
+" Command Aliases  {{{
+command! -nargs=+ CAlias call vimrc#CommandAlias(<f-args>)
+CAlias Q q
+CAlias W w
+
+" make these default to one window/buffer too
+CAlias  doc      ViewDoc!
+CAlias  help     ViewDocHelp!
+CAlias  man      ViewDocMan!
+CAlias  perldoc  ViewDocPerl!
+"}}}
+
 "}}}
 
 " General settings  {{{

mercurial