Last active
December 21, 2015 06:18
-
-
Save mopp/6262980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let lst = [ ['<', "smartchr#loop(' < ', ' << ', '<')" ], | |
\ ['>', "smartchr#loop(' > ', ' >> ', ' >>> ', '>')"], | |
\ ['+', "smartchr#loop(' + ', ' ++ ', '+')"], | |
\ ['-', "smartchr#loop(' - ', ' -- ', '-')"], | |
\ ['/', "smartchr#loop(' / ', '//', '/')"], | |
\ ['&', "smartchr#loop(' & ', ' && ', '&')"], | |
\ ['%', "smartchr#loop(' % ', '%')"], | |
\ ['*', "smartchr#loop(' * ', '*')"], | |
\ ['<Bar>', "smartchr#loop(' | ', ' || ', '|')"], | |
\ [',', "smartchr#loop(', ', ',')"]] | |
for i in lst | |
call smartinput#map_to_trigger('i', i[0], i[0], i[0]) | |
call smartinput#define_rule({ 'char' : i[0], 'at' : '\%#', 'input' : '<C-R>=' . i[1] . '<CR>'}) | |
call smartinput#define_rule({'char' : i[0], 'at' : '^\([^"]*"[^"]*"\)*[^"]*"[^"]*\%#', 'input' : i[0]}) | |
call smartinput#define_rule({ 'char' : i[0], 'at' : '^\([^'']*''[^'']*''\)*[^'']*''[^'']*\%#', 'input' : i[0] }) | |
endfor | |
call smartinput#define_rule({'char' : '>', 'at' : ' < \%#', 'input' : '<BS><BS><BS><><Left>'}) | |
call smartinput#map_to_trigger('i', '=', '=', '=') | |
call smartinput#define_rule({ 'char' : '=', 'at' : '\%#', 'input' : "<C-R>=smartchr#loop(' = ', ' == ', '=')<CR>"}) | |
call smartinput#define_rule({ 'char' : '=', 'at' : '[&+-/<>|] \%#', 'input' : '<BS>= '}) | |
call smartinput#define_rule({ 'char' : '=', 'at' : '!\%#', 'input' : '= '}) | |
call smartinput#define_rule({ 'char' : '=', 'at' : '^\([^"]*"[^"]*"\)*[^"]*"[^"]*\%#', 'input' : '='}) | |
call smartinput#define_rule({ 'char' : '=', 'at' : '^\([^'']*''[^'']*''\)*[^'']*''[^'']*\%#', 'input' : '='}) | |
call smartinput#map_to_trigger('i', '<BS>', '<BS>', '<BS>') | |
call smartinput#define_rule({ 'char' : '<BS>' , 'at' : '(\s*)\%#' , 'input' : '<C-O>dF(<BS>'}) | |
call smartinput#define_rule({ 'char' : '<BS>' , 'at' : '{\s*}\%#' , 'input' : '<C-O>dF{<BS>'}) | |
call smartinput#define_rule({ 'char' : '<BS>' , 'at' : '<\s*>\%#' , 'input' : '<C-O>dF<<BS>'}) | |
call smartinput#define_rule({ 'char' : '<BS>' , 'at' : '\[\s*\]\%#' , 'input' : '<C-O>dF[<BS>'}) | |
for op in ['<', '>', '+', '-', '/', '&', '%', '\*', '|'] | |
call smartinput#define_rule({ 'char' : '<BS>' , 'at' : ' ' . op . ' \%#' , 'input' : '<BS><BS><BS>'}) | |
endfor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment