Close Menu
  • Analog Design
    • Latest Analog Layout Interview Questions (2025)
  • Digital Design
    • Digital Electronics Interview Question(2025)
    • Top VLSI Interview Questions
  • Physical Design
    • Physical Design Interview Questions for VLSI Engineers
  • Verilog
    • Verilog Interview Questions(2024)
  • Forum
Facebook Instagram YouTube LinkedIn WhatsApp
SiliconvlsiSiliconvlsi
Forum Questions Register in Forum Login in Forum
Facebook Instagram YouTube LinkedIn WhatsApp
  • Analog Design
    • Latest Analog Layout Interview Questions (2025)
  • Digital Design
    • Digital Electronics Interview Question(2025)
    • Top VLSI Interview Questions
  • Physical Design
    • Physical Design Interview Questions for VLSI Engineers
  • Verilog
    • Verilog Interview Questions(2024)
  • Forum
SiliconvlsiSiliconvlsi
Home»Linux»Delete words after certain word in each line in gvim
Linux

Delete words after certain word in each line in gvim

siliconvlsiBy siliconvlsiJanuary 28, 2024Updated:January 28, 2024No Comments2 Mins Read
Facebook Pinterest LinkedIn Email WhatsApp
Share
Facebook Twitter LinkedIn Pinterest Email

In GVim, you can use regular expressions and the substitution command (:s) to delete words after a certain word in each line. Here’s a basic example:

Let’s say you want to delete words after the word “certain” in each line. You can use the following command:

:%s/\v(certain\s+).\+/\1/g

Explanation:

:%s/: This initiates a substitution command for the entire file.

\v: Enables “very magic” mode, which simplifies the syntax of regular expressions.

(certain\s+): This captures the word “certain” followed by one or more whitespace characters.

.\+: This matches one or more of any character (except for a newline).

/: Separates the search pattern and the replacement.

\1: Refers to the content captured within the first set of parentheses (i.e., “certain\s+”).

/g: Performs the substitution globally on each line.

Make sure to adapt the search pattern based on your specific use case. If you want to delete words after a different word, replace “certain” with your desired keyword.

 

Example

Let’s say you have the following lines in your GVim editor:

This is a certain example sentence.
Please edit this certain paragraph.
I need help with a certain problem.

And you want to delete words after the word “certain” in each line. You can use the following GVim command:

:%s/\v(certain\s+).\+/\1/g
After running this command, your text will be transformed to:
This is a certain
Please edit this certain
I need help with a certain
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email

Related Posts

Linux date Command

January 22, 2024

What is a Linux locate Command?

January 22, 2024

du Command in Linux

January 20, 2024
Leave A Reply Cancel Reply

Facebook X (Twitter) Instagram Pinterest Vimeo YouTube
  • About Us
  • Contact Us
  • Privacy Policy
© 2025 Siliconvlsi.

Type above and press Enter to search. Press Esc to cancel.