Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How can I CamelCase-enable Vim Search
  2. nnoremap <expr> <leader>/ SearchCamelCase('/')
  3. nnoremap <expr> <leader>? SearchCamelCase('?')
  4. function! SearchCamelCase(dir)
  5.     call inputsave()
  6.     let ab = input(a:dir)
  7.     call inputrestore()
  8.     let l = filter(split(toupper(ab), 'zs'), 'v:val =~ "\w"')
  9.     if len(l) > 0
  10.         let l[0] = '[' . l[0] . tolower(l[0]) . ']'
  11.     end
  12.     let @/ = 'C<' . join(map(l, 'v:val . "[0-9a-z_]*"'), '') . '>'
  13.     return a:dir . "r"
  14. endfunction