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.

Était-ce utile?

La 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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top