Refactoring in Vim

前端 未结 15 1950
醉梦人生
醉梦人生 2021-01-29 17:44

Of course the fact that you can refactor on IDEs is priceless for many, I hardly ever do it when I am coding but I may try to do it when editing some one else\'s source. How do

15条回答
  •  -上瘾入骨i
    2021-01-29 18:35

    Go

    1. The tool godoctor (github) supports several refactoring capabilities
    • Rename
    • Extract Function
    • Extract Local Variable
    • Toggle var ⇔ :=
    • Add Godoc stubs

    There is a vim plugin https://github.com/godoctor/godoctor.vim which makes them available

    With cursor in thing to rename:

    :Rename 
    

    Highlighting block to extract:

    :Refactor extract newfunc
    
    1. vim-go

      • Precise type-safe renaming of identifiers with :GoRename.
    2. Language server gopls

      • https://github.com/golang/tools/blob/master/gopls/doc/status.md#rename

提交回复
热议问题