2 Answers
2

See this hint on the vim wiki for how to have correct indention even for empty lines. If you just want to keep the previous indent (ignoring what vim calculated as the correct indent) use let ind = indent(prevnonblank(v:lnum - 1)) like explained in a comment under the same wiki entry.