Chris Stryczynski

Software Developer / Consultant

My Vim Fu Regex

Posted on: 14/04/2017

Change letter to upper case after each dollar sign (useful for PHP / Perl / Shell variable): s/\$\(.\)/\$\U\1/g

Input: $abcXyzYolo Output: $AbcXyzYolo


Replace every } with ; } if it does NOT (have a ; and some possible white space before it OR it has only white space characters before), this uses a look behind:

%s/\(.*;\s*\|^\s*\)\@<!}/; }/g


Input:

example { abcxyz }
example2 { abcxyz ; }
   }

Output:

example { abcxyz ; }
example2 { abcxyz ; }
  }
Comments

No comments, yet!

Submit a comment