Skip to content

using goimports for go_fmt_command moves the cursor on save #1342

Closed
@clee

Description

@clee

Behavior

Anytime I add or delete a line that requires adding or deleting an import, my cursor gets moved when I save the file (when adding a line, my cursor gets moved up one line from where I was; when I delete a line, the cursor gets moved down a line, because goimports has added or removed lines). It would be nice if my cursor stayed locked to the same line of code I was on already, before saving.

Steps to reproduce:

  1. make sure to configure vim with let g:go_fmt_command = "goimports"
  2. open a new Go file (using the default template)
  3. add a line after fmt.Println("vim-go") with the contents:
    user := os.Getenv("user")
  4. position cursor on just-inserted line, at the u in user
  5. save the file with :w

Configuration

  • vimrc contains only let g:go_fmt_command = "goimports"
  • vim version: NVIM v0.2.1-15-g08b23d08
  • vim-go version: bcf3f23
  • go version: go1.8.2 darwin/amd64

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions