Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "---------------------------------------
- " Replace
- set report=0
- xnoremap S <Nop>
- " replace the user input in the current line
- nnoremap s :<C-u>s//g "<Left><Left><Left><Left>
- " replace the cword in the current line
- nnoremap ,ls :<C-u>s/\<<C-r>=expand('<cword>')<CR>\>//g "<Left><Left><Left><Left>
- nnoremap ,lS :<C-u>s/<C-r>=expand('<cword>')<CR>//g "<Left><Left><Left><Left>
- " replace the selection in the current line
- xnoremap ,ls "vy:s/\<<C-r>=<SID>reg_v_value()<CR>\>//g "<Left><Left><Left><Left>
- xnoremap ,lS "vy:s/<C-r>=<SID>reg_v_value()<CR>//g "<Left><Left><Left><Left>
- " replace the user input in the current buffer
- nnoremap S :<C-u>%s//g "<Left><Left><Left><Left>
- " replace the cword in the current buffer
- nnoremap ,s :<C-u>%s/\<<C-r>=expand('<cword>')<CR>\>//g "<Left><Left><Left><Left>
- nnoremap ,S :<C-u>%s/<C-r>=expand('<cword>')<CR>//g "<Left><Left><Left><Left>
- " replace the selection in the current buffer
- xnoremap ,s "vy:%s/\<<C-r>=<SID>reg_v_value()<CR>\>//g "<Left><Left><Left><Left>
- xnoremap ,S "vy:%s/<C-r>=<SID>reg_v_value()<CR>//g "<Left><Left><Left><Left>
- " replace the user input in the selection
- xnoremap s :s//g "<Left><Left><Left><Left>
- " replace the yanted text in the selection
- xnoremap ,vy :s/\<<C-r>=@"<CR>\>//g "<Left><Left><Left><Left>
- xnoremap ,vY :s/<C-r>=@"<CR>//g "<Left><Left><Left><Left>
- " replace the user input in the last selected
- nnoremap ,vv :<C-u>%s/\%V/g "<Left><Left><Left><Left>
- " replace the cword in the last selected
- nnoremap ,vs :<C-u>%s/\%V\<<C-r>=expand('<cword>')<CR>\>//g "<Left><Left><Left><Left>
- nnoremap ,vS :<C-u>%s/\%V<C-r>=expand('<cword>')<CR>//g "<Left><Left><Left><Left>
- " replace the yanted text in the last selected
- nnoremap ,vy :<C-u>%s/\%V\<<C-r>=@"<CR>\>//g "<Left><Left><Left><Left>
- nnoremap ,vY :<C-u>%s/\%V<C-r>=@"<CR>//g "<Left><Left><Left><Left>
- " replace the user input in buffers
- nnoremap <Leader>: :<C-u>%bufdo s//g "<Left><Left><Left><Left>
- " replace the cword in buffers
- nnoremap <Leader>s :<C-u>bufdo %s/\<<C-r>=expand('<cword>')<CR>\>//g "<Left><Left><Left><Left>
- nnoremap <Leader>S :<C-u>bufdo %s/<C-r>=expand('<cword>')<CR>//g "<Left><Left><Left><Left>
- " replace the selection in buffers
- xnoremap <Leader>s "vy:bufdo %s/\<<C-r>=<SID>reg_v_value()<CR>\>//g "<Left><Left><Left><Left>
- xnoremap <Leader>S "vy:bufdo %s/<C-r>=<SID>reg_v_value()<CR>//g "<Left><Left><Left><Left>
- function! s:reg_v_value()
- return substitute(s:escape_regexp(@v), "\n", '\\n', 'g')
- endfunction
- function! s:escape_regexp(str)
- return escape(a:str, '^$[].*\~' . '/')
- endfunction
Add Comment
Please, Sign In to add comment