diff --git a/autoload/crunch.vim b/autoload/crunch.vim index 6ef6987..9de3a0a 100644 --- a/autoload/crunch.vim +++ b/autoload/crunch.vim @@ -78,7 +78,10 @@ function! crunch#eval(exprs) abort "{{{2 " Decho '== Inizilation ==' let s:variables = deepcopy(g:crunch_user_variables, 0) - let expr_list = split(a:exprs, '\n', 1) + let separator_magic = "\t \t \t\n" + + let processed_exprs = substitute(a:exprs, ';', separator_magic, 'g') + let expr_list = split(processed_exprs, '\n', 1) " Decho 'expr_list = <'.string(expr_list).'>' for i in range(len(expr_list)) @@ -108,7 +111,9 @@ function! crunch#eval(exprs) abort "{{{2 let expr_list[i] = s:build_result(orig_expr, result) endfor " Decho string(expr_list).'= the expr_lines_list' - let expr_lines = join(expr_list, "\n") + let expr_separator = "\n" + let expr_lines = join(expr_list, expr_separator) + let expr_lines = substitute(expr_lines, separator_magic, ';', 'g') " Decho expr_lines.'= the expr_lines' let s:variables = {} return expr_lines diff --git a/doc/crunch.txt b/doc/crunch.txt index 150b8c0..d9c9621 100644 --- a/doc/crunch.txt +++ b/doc/crunch.txt @@ -160,6 +160,15 @@ evaluate the expressions and see the results. area = pow(radius,2)*pi = 78.5375 volume = pow(radius,3)*pi*4/3 = 523.583333 +Could use ";" to separate different expressions in one line. For the following +line: + +"a = 3; b = 7; c = a * b" + +When press `g=i"`, you will get: + +"a = 3; b = 7; c = a * b = 21" + ------------------------------------------------------------------------------ User defined variables. diff --git a/test/operator.vader b/test/operator.vader index e20d684..c2de4c8 100644 --- a/test/operator.vader +++ b/test/operator.vader @@ -21,6 +21,13 @@ Expect: 5*5 = 25 ############################################################################## Given: + a = 3; b = 7; c = a*b +Do (Test Operator: single line with variable): + g== +Expect: + a = 3; b = 7; c = a*b = 21 +############################################################################## +Given: 5*5 Do (Test Operator: inner word): g=iW