How to delete (not cut) in Vim?

前端 未结 6 561
别那么骄傲
别那么骄傲 2021-01-29 17:52

How can I delete a line without putting it into my default buffer?

Example:

line that will be copied.

line that I want to be substitued with the previou         


        
6条回答
  •  灰色年华
    2021-01-29 18:22

    the following mappings will produce:

    • d => "delete"
    • leader d => "cut"
    nnoremap x "_x
    nnoremap d "_d
    nnoremap D "_D
    vnoremap d "_d
    
    nnoremap d ""d
    nnoremap D ""D
    vnoremap d ""d
    

    Also, it is a nice practice to have the "leader" key set to comma, e.g:

    let mapleader = ","
    let g:mapleader = ","
    

    these 2 snippets will make ",d" be your new cut command.

    If you would like to use these mappings togther with a shared system clipboard configuration, see further details at https://github.com/pazams/d-is-for-delete

提交回复
热议问题