public TextEditor detabify ( final int tabWidth ) { replaceAll ( Pattern . compile ( "(.*?)\\t" ) , new Replacement ( ) { public String replacement ( Matcher m ) { String lineSoFar = m . group ( 1 ) ; int width = lineSoFar . length ( ) ; StringBuilder replacement = new StringBuilder ( lineSoFar ) ; do { replacement . append ( ' ' ) ; ++ width ; } while ( width % tabWidth != 0 ) ; return replacement . toString ( ) ; } } ) ; return this ; }
Convert tabs to spaces .