Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top