In Vim, how can I delete everything between quotes including the quotes?

后端 未结 3 1710
庸人自扰
庸人自扰 2020-12-28 12:42

For example, in the following:

Testing \"deleting\" within quotes

With the cursor inside of deleting, how can I delete the text within the

3条回答
  •  心在旅途
    2020-12-28 13:10

    We can use

    da"
    

    for your case or di" to delete ONLY the contents inside of ".

    It is better to start with text-objects. Writing as an answer for completeness. Excerpt from :h text-objects, given below, suggest two forms i and a

    This is a series of commands that can only be used while in Visual mode or after an operator. The commands that start with "a" select "a"n object including white space, the commands starting with "i" select an "inner" object without white space, or just the white space. Thus the "inner" commands always select less text than the "a" commands.

    text-objects are useful to other character pair like (), {}, etc. For example, it is useful while changing

    if ( i == true ) {
    }
    

    to

    if (_) {
    }
    

    by using ci( or ci).

提交回复
热议问题