1

I am trying to remove whitespace at the beginning of a tabstop using transformations. I have found that the regex \S+ should return all characters that aren't whitespace.

snippet getset "Create a get/set pair" b
${1:type} get${2:name}(){ return ${2/.*/\l$0/}; }
void set$2(${1/(\S+)/$0/g} new$2){ ${2/.*/\l$0/} = new$2; }
endsnippet

The regex that makes trouble is in the third line. I always get back the entire unaltered tabstop, including the whitespace, no matter that the regex is. I've tried (a) and I still got the entire tabstop back:

    arma::vec3 getname(){ return name; }
    void setname(   arma::vec3 newname){ name = newname; }

Are there any obvious things I am missing, or did I stumble upon a bug?

DrLuke
  • 11
  • 2
  • Well I don't have ultisnips but I don't think your regex actually does anything. I assume you are replacing non whitespace with it self leaving the whitespace unaltered. I think you want to do something like `:s/^\s\+//` to remove the leading whitespace. – FDinoff Dec 18 '14 at 19:12
  • That's not it, it still returns the entire tabstop (Even with an empty regex!). I found an acceptable workaround by disabling a certain indent behaviour, so I don't get any disturbing whitespace characters anymore. – DrLuke Dec 19 '14 at 06:19
  • An empty regex matches nothing. So it won't remove anything (however if you wanted it could add something inbetween every character). Also `\S+` is a very magic regex (assuming ultisnips uses vim regex and not some other regex flavor), and the regex I gave you before was just a magic one so you most likely need to remove the ``\`` from the `\+` – FDinoff Dec 19 '14 at 15:12
  • From what I gathered UltiSnips uses python regex, as it is written in python. – DrLuke Dec 19 '14 at 22:48

0 Answers0