Skip to content.

A Note About Website Navigation

Skip to main menu.

For users of screen readers, depending on the screen resolution, the two checkboxes are for opening and closing the side menus that appear to the left and right side of the screen. This is designed both for large screens and for mobile devices with a touch screen. Checking either the main menu or sidebar checkboxes causes the menu to open from the left or right side of the screen, respectively. Clearing the checkox in either the main menu or sidebar closes the menu. The checkboxes are visible to screen readers such as JAWS and NVDA for Windows, Voiceover for Mac, and Orca screen reader for Linux. When a screen reader says "clickable" for both main menu and sidebar, that is for the respective checkboxes. End of explaination.

Viewing Single Blog Post

Vim: How to Delete Text Enclosed In Quotes

Instructions

Navigate to the first character after the quote/double-quote and type the following in Vim:

di"

This is useful if you have something like the following:

{
    "title": "Vim: How to Delete Text Enclosed In Quotes",
    "permalink": "vim-how-to-delete-text-enclosed-in-quotes",
    "published": "2023-08-12 14:00",
    "categoryIDs": "5,5:0,5:1,5:5",
    "description": "In Vim, 'di\"' is the one to use for deleting text in quotes.",
    "thumbnail": "",
    "smallimage": "",
    "largeimage": ""
}

So, to navigate to the first character that starts with a double-quote, simply type /"e; and the insertion point will highlight the double-quote. To get to the next double-quote, press the n key again until you get to the one you want. After that, press the l key to move to the first character and type the following:

di"

The output will be as follows:

{
    "title": "",
    "permalink": "vim-how-to-delete-text-enclosed-in-quotes",
    "published": "2023-08-12 14:00",
    "categoryIDs": "5,5:0,5:1,5:5",
    "description": "In Vim, 'di\"' is the one to use for deleting text in quotes.",
    "thumbnail": "",
    "smallimage": "",
    "largeimage": ""
}

And now, you can type whatever you want by pressing the i key on your keyboard. Press the ESC (escape) key to get out of INSERT mode and back into normal mode. To save changes and quit the Vim text editor, type :wq.

Bonus: If you have delimiters with quotes while writing the code such as:

"This is some \"quote\"!"

Vim will automatically delete the delimiters with quotes along with them, so performing di" will delete everything that is in between quotes.

""

And you do not need to be inside quotes in order to delete inside the quotes! How cool is that? *grinning face*

Oh, and you can also use the "change inside" sequence as well:

ci"
This puts you into INSERT mode so you can type text inside quotes.

Audience

This is for Linux users experienced in using the Vim text editor. Vim users should already know the basics such as :q! for quitting the text editor without saving changes, :wq for saving changes and quitting the text editor, i for going into INSERT mode and use the ESC (escape) key to get back into normal mode. All keyboard commands are beyond the scope of this short article that I wrote.

Conclusion

Hopefully this keyboard command can be of help to you. If you are a Linux user, please give Vim a try.

Original Source

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

Note that I was searching for information about deleting text inside quotes and not including the quotes.


Article published: 2023-08-12 14:00

Categories: The World of Computers, Computers, Information Technology, Scripting and Programming,

About Grayson Peddie

Hello! I am a web developer and I have a passion for the world of Information Technology. I currently hold 4 CompTIA certificates (A+, Network+, Security+, and CySA+) including Cisco's CCNA (Cisco Certified Network Associate) certificate. Speaking of web development, I am a web accessibility enthusiast. I make sure that users of screen readers and keyboard users who cannot use a mouse can be able to access my website with just only the keyboard. Plus, I have learned a whole lot about Web Content Accessibility Guidelines.

So what are my hobbies? Aside from web development, I watch Star Trek: The Next Generation from time to time during the nights. I listen to music from the likes of David Arkenstone, Yanni, Checkfield, Cucso, Looreena McKennitt, Clannad, 2002, Enya, and even soundtrack from EPCOT Center (1982-1994), Tomorrowland, WALL-E, and TRON: Legacy. Oh, yes! Tomorrowland, TRON: Legacy, and WALL-E are the three movies I watch during Friday nights and every Friday night is my pizza night. I'm an optimist who likes to see what kind of future the world would look like. That's why I follow The Venus Project on Twitter (here's the website to The Venus Project. I do have a lot to cover in my introductory article in my website, so if you want to go in-depth and know more about me, that is the article to visit.