Skip to content

Commit 4d57879

Browse files
bugfix: command Rbeg (bad working with selection from the function fixed)
1 parent 9e714a1 commit 4d57879

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
4444
* English Dictionary completion
4545
* Commands
4646
* 'ctabs' : convert tabs into 4 spaces
47-
* 'rbeg' \<NUM-CHARS\> \<REPLACE-WITH\> : Replace beginning characters of a selection
47+
* 'Rbeg' \<NUM-CHARS\> \<REPLACE-WITH\> : Replace beginning characters of a selection
4848
* Control + b : change buffer files
4949
* Control + i : Indent all lines
5050
* Control + e : Got to the next error

vimrc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ noremap <C-b> :bn<CR>
3232
noremap <C-i> gg=G
3333
3434
""" FUNCTIONS
35-
function! ReplaceBeginningChars(numChars, replaceWith)
36-
execute ":'<,'>s/^\\.\\{" . a:numChars . "}/" . a:replaceWith . "/"
35+
function! ReplaceBeginningChars(numChars, newText) range
36+
let l:pattern = '^.\{' . a:numChars . '}\ze'
37+
execute a:firstline . ',' . a:lastline . 's/' . l:pattern . '/' . a:newText . '/'
3738
endfunction
38-
command! -nargs=+ rbeg call ReplaceBeginningChars(<f-args>)
39+
40+
command! -nargs=+ -range=% Rbeg :<line1>,<line2>call ReplaceBeginningChars(<f-args>)
3941

4042
"""" Ale Pluging Configuration by Victor Mours (Reference 4 in notes.md)
4143
nmap <silent> <C-e> <Plug>(ale_next_wrap)

0 commit comments

Comments
 (0)