Adding characters at the start and end of each line in a file

In vim, you can do

:%s/^\(.*\)$/"\1"/
  • s/regex/replace/ is vim command for search n replace.
  • % makes it apply throughout the file
  • ^ and $ denotes start and end of the line respectively.
  • (.*) captures everything in between. ( and ) needs to be escaped in vim regexes.
  • \1 puts the captured content between two quotes.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)