Merge pull request #302 from tanuck/align-tabs-with-spaces

Correct the number of spaces in a tab
This commit is contained in:
Zachary Yedidia
2016-09-04 10:58:12 -04:00
committed by GitHub

View File

@@ -687,6 +687,9 @@ func (v *View) InsertTab(usePlugin bool) bool {
// Insert a tab
if v.Buf.Settings["tabstospaces"].(bool) {
tabSize := int(v.Buf.Settings["tabsize"].(float64))
if remainder := v.Cursor.Loc.X % tabSize; remainder != 0 {
tabSize = tabSize - remainder
}
v.Buf.Insert(v.Cursor.Loc, Spaces(tabSize))
for i := 0; i < tabSize; i++ {
v.Cursor.Right()