7

For example, I might accidentally type something like :WQ and I want it to work like :wq when a hit enter

Another case is where I am typing a longer command name, for example NERDTreeTabsClose. (Note that I have the settings ignorecase and smartcase set)

  1. I might start by typing :nerd and then hitting tab, which will auto complete to :NERDTree
  2. I might then type a little more so that the command mode shows :NERDTreetab and then I hit tab again.
  3. Because I have smart case on, the auto complete will not work. The ideal scenario would be for the auto complete to work

I would like to keep smartcase on, because that is useful for searches with /.

Is there a way to achieve the behaviour have described above

2

2 Answers 2

11

You can dynamically toggle smartcase using autocmds, so when in a : command line, it is off and when in a / command line it is on:

" assumes set ignorecase smartcase
augroup dynamic_smartcase
    autocmd!
    autocmd CmdLineEnter : set nosmartcase
    autocmd CmdLineLeave : set smartcase
augroup END
0
1

I've personally found https://github.com/thinca/vim-ambicmd to be fairly useful for long commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.