Friday, February 21, 2014

rxvt-unicode - not to select trailing blanks in vim

Everytime I do mouse selection in my vim (run in rxvt-unicode) and paste the content to another place, I will select all trailing blanks in every line. It's a very annoying problem.

Finally I found the solution in

http://www.reddit.com/r/emacs/comments/1ox5pf/why_fill_the_empty_space_with_spaces/

I followed the article and added the following options in my ~/.Xdefault:

URxvt.perl-ext-common: default,selection-autotransform
URxvt.selection-autotransform.0: s/ +$//gm 
It removes trailing blanks by perl and everything works as I want now. Thanks for this article!

1 comment:

yegle said...

In case anyone found this page from google search and can't make this to work:

For some reason it doesn't work with rxvt-unicode 9.22. ~/.xsession-errors contains the error:

urxvt: s/ +$: Substitution pattern not terminated at (eval 25) line 1.[]

Looks like // in ~/.xdefauts file is considered the beginning of a comment.

My solution is to use alternative delimiters other than forward slash /. E.g. you can write something like this:

urxvt.selection-autotransform.0: s|[ ]+$||gm