Skip to content

Respect original bra and ket when changing function  #171

@YuruiHong

Description

@YuruiHong

I personally prefer the vim-surround grammar. When using csff<function name> to change a function name for a language that does not use () for functions, e.g. Mathematica using [], my configuration is like:

augroup sandwich-ft-mma
  autocmd BufRead,BufNewFile *.wl let b:sandwich_magicchar_f_patterns = [
                              \   {
                              \     'header' : '\<\%(\h\k*\.\)*\h\k*',
                              \     'bra'    : '\[',
                              \     'ket'    : '\]',
                              \     'footer' : '',
                              \   },
                              \ ]
augroup END

For the function below:

f[x_] := x^2

When my cursor is in the brackets, dsf can successfully delete the function to make it x_. However, when I tried to rename f to g using csffg, the result was:

g(x_) := x^2

It seems the [] brackets matched by bra and ket patterns were ignored in the final output, and the behavior of csff always assumes () are used for function calls. I wonder if it's better to respect the original surrounding characters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions