Vim smart insert semicolon

前端 未结 7 941
遇见更好的自我
遇见更好的自我 2021-02-04 00:49

Is there a Vim plugin that can handle smart semicolon insertion, like the one in Eclipse?

Example (pipe character is insertion cursor):

foobar(|)
         


        
7条回答
  •  名媛妹妹
    2021-02-04 01:16

    I use the following function and a mapping to insert a semicolon to the end of the line and to delete the remaning spaces:

    imap . =Semicolonfun()
    fun! Semicolonfun() "{{{
      call setline(line('.'), substitute(getline('.'), '\s*$', ';', ''))
      return "\"
    endfunction "}}}
    

    So if you have something like:

    log.warning("you miss the |identifier")
    

    Pressing . or ,. if you remap the leader, you get the following:

    log.warning("you miss the identifier");|
    

提交回复
热议问题