+ dir, _ := homedir.Dir()
+ b.Path = strings.Replace(filename, "~", dir, 1)
+ if b.Settings["rmtrailingws"].(bool) {
+ r, _ := regexp.Compile(`[ \t]+$`)
+ for lineNum, line := range b.Lines(0, b.NumLines) {
+ indices := r.FindStringIndex(line)
+ if indices == nil {
+ continue
+ }
+ startLoc := Loc{indices[0], lineNum}
+ b.deleteToEnd(startLoc)
+ }
+ b.Cursor.Relocate()
+ }