Tip to replace text easily in VIM equivalent to Ctrl + F

Like all text editors VIM can replace text with another text, but this function is not accessible by the traditional Ctrl + F. You must type a command line in VIM to be able to do:

:1,$s/text a remplacer/text de substitution/g

It seems a little barbaric to read, but it's very simple. Let's detail this command line:

  • ":" allows to invoke a function in VIM
  • "1" represents the first line of the file and can therefore vary
  • "$" represents the last line of the file and can therefore also vary
  • "s" the invoked command
  • "/" are text delimiters. If your text contains /, it will be necessary to escape them with a \
  • "g" allows to do a global search and therefore to replace all occurrences. This is an option that can be omitted.

I hope this tip will be as useful to you as to me.

Comments are temporary disable because of spammers.

Search

Post's details