Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So I have the following text snippet in my file. I am using vim to edit it.

Internal Problem Description
----------------------------
!!! Please enter the internal description of the problem.

So to fill up the problem description I go to the line that starts with !!! and then first do a dd and then press I to go to insert mode. Then I start typing text for the problem description.

Is there a better way to achieve this? Something like replacing an entire line in vim with a single command.

share|improve this question
1  
Maybe stackoverflow.com/questions/8296473/… is helpful: pressing 'C' will delete the rest of the line and go to insert mode –  brm Jan 13 at 17:10
    
@brm Thanks for the link. –  Geek Jan 13 at 17:18

2 Answers 2

up vote 4 down vote accepted
  1. Jump to the line that starts with the bangs with something like:

    /!!<CR>
    
  2. Enter insert mode with:

    S
    

    or

    cc
    

See :help S.

share|improve this answer
    
What is <CR>? –  Geek Jan 14 at 6:25
    
The enter key. See :help key-notation. –  romainl Jan 14 at 7:39

The S command will do that. But you should also look into a snippet solution, which allows multiple placeholders and automatic jumping to them.

snippets are like the built-in :abbreviate on steroids, usually with parameter insertions, mirroring, and multiple stops inside them. One of the first, very famous (and still widely used) Vim plugins is snipMate (inspired by the TextMate editor); unfortunately, it's not maintained any more; though there is a fork. A modern alternative (that requires Python though) is UltiSnips. There are more, see this list on the Vim Tips Wiki.

share|improve this answer
    
what does S stand for? Also what do you mean by ":abbreviate on steroids". Can you please give me some context? –  Geek Jan 13 at 17:16
    
It's a command name, probably a mnemonic for Substitute. You apparently use snippet files which you :read into the buffer, but for small text fragments like yours, defining :abbreviations directly in Vim would work, too. Snippets are even more powerful, as I've described. –  Ingo Karkat Jan 14 at 7:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.