3

Configuration

  • Windows 7 Service Pack 1 (64-bit)
  • VIM 7.4 (2013 Aug 10), 32-Bit GUI version
  • cscope_macros.vim plugin from www.vim.org, version 2.0.0

The problem

The plugin maps several cscope find functions to open in horizontal or vertical splits using 'CTRL-spacebar' or <CTRL-@>, as this is how VIM recognises it according to the plugin documentation. here is a snippet from the plugin:

" Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
" makes the vim window split horizontally, with search result displayed in
" the new window.
"
" (Note: earlier versions of vim may not have the :scs command, but it
" can be simulated roughly via:
"    nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR>  

nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR> 
nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR> 

However, 'CTRL-spacebar' does not work. When I look at what has been mapped <C-@> is actually translated as <nul>. For example, if I use the command :map, this is the result for the cscope plugin mapped keys.

n   <nul>d        :scs find d <C-R>=expand("<cword>")<CR><CR><Tab>
n   <nul>i        :scs find i <C-R>=expand("<cfile>")<CR><CR><Tab>
n   <nul>f        :scs find f <C-R>=expand("<cfile>")<CR><CR><Tab>
n   <nul>e        :scs find e <C-R>=expand("<cword>")<CR><CR><Tab>

The only thing I can find 'CTRL-spacebar'/<CTRL-@> (:help index) is

tag     char        action in Insert mode   ~
-----------------------------------------------------------------------
i_CTRL-@    CTRL-@      insert previously inserted text and stop
                        insert

But this is not the behaviour I observe.

When I try using 'CTRL-spacebar' in insert mode all that happens is that a space is inserted at the cursor. When I use it in normal mode it seems to move the cursor to the beginning of the next word, or the next line if it is blank.

So, how do I map 'CTRL-spacebar' in VIM on windows?

Simon Peverett
  • 4,128
  • 3
  • 32
  • 37

1 Answers1

5

In Windows GVIM, use the straightforward <C-Space> as the left-hand side of the mapping. <C-@> or the equivalent <Nul> is a workaround for the (Linux) terminal, which in general offers fewer mappable keys. The instructions were presumably aimed at that only.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324