Surround every line in a file using sed
To replace every line in a file you can use linux's built in sed utility:
For example given a file like this:
dkarter/backpack
junegunn/fzf
junegunn/fzf.vim
junegunn/vim-peekaboo
junegunn/gv.vim
terryma/vim-multiple-cursors
scrooloose/nerdtree
dyng/ctrlsf.vim
haya14busa/incsearch.vim
killphi/vim-legend
neomake/neomake
If we want to surround each line with Plug '$content_of_line'
we can run the following command:
sed -e "s/\(.*\)/Plug '\1'/" .vimbundle.local
Output:
Plug 'dkarter/backpack'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'junegunn/vim-peekaboo'
Plug 'junegunn/gv.vim'
Plug 'terryma/vim-multiple-cursors'
Plug 'scrooloose/nerdtree'
Plug 'dyng/ctrlsf.vim'
Plug 'haya14busa/incsearch.vim'
Plug 'killphi/vim-legend'
Plug 'neomake/neomake'
If the result is what we expected we can add -i
flag to write the file in place, updating it with our changes:
sed -ie "s/\(.*\)/Plug '\1'/" .vimbundle.local
Tweet