0

Is there a plugin or snippet that I can use to automcomplete -> or => by pressing - or = + tab?

I just can't stand typing > all the time.

I tried creating the following snippets for snipmate, but they don't work because - and = are affixed to the end of a variable.

Charles
  • 50,943
  • 13
  • 104
  • 142
Bryan
  • 17,201
  • 24
  • 97
  • 123

1 Answers1

2

Here's a snippet for you:

:inoremap <expr> <Tab> getline('.')[col('.')-2]=~#'[-=]' ? ">" : "\<Tab>"

This is an expression mapping that maps <Tab> in insert mode to > if the character before the cursor is either - or =.

See :h :map-expression.

glts
  • 21,808
  • 12
  • 73
  • 94