diff --git a/cmd/micro/actions.go b/cmd/micro/actions.go index a8b8a7b8..58040a55 100644 --- a/cmd/micro/actions.go +++ b/cmd/micro/actions.go @@ -309,6 +309,16 @@ func (v *View) Delete() bool { func (v *View) InsertTab() bool { // Insert a tab if v.Cursor.HasSelection() { + if v.Cursor.CurSelection[0].Y != v.Cursor.CurSelection[1].Y { + for i := v.Cursor.CurSelection[0].Y; i <= v.Cursor.CurSelection[1].Y; i++ { + if settings["tabstospaces"].(bool) { + v.Buf.Insert(Loc{0, i}, Spaces(int(settings["tabsize"].(float64)))) + } else { + v.Buf.Insert(Loc{0, i}, "\t") + } + } + return true + } v.Cursor.DeleteSelection() v.Cursor.ResetSelection() } diff --git a/cmd/micro/cursor.go b/cmd/micro/cursor.go index 2caffae6..03ddf159 100644 --- a/cmd/micro/cursor.go +++ b/cmd/micro/cursor.go @@ -293,7 +293,6 @@ func (c *Cursor) Start() { func (c *Cursor) GetCharPosInLine(lineNum, visualPos int) int { // Get the tab size tabSize := int(settings["tabsize"].(float64)) - // This is the visual line -- every \t replaced with the correct number of spaces visualLineLen := StringWidth(c.buf.Line(lineNum)) if visualPos > visualLineLen { visualPos = visualLineLen