Hi,
The call to histdel below doesn't seem to be doing what I want it to do.
The call to histdel below doesn't seem to be doing what I want it to do.
It doesn't delete my 3 search patterns added by the 2 :substitute and the :global calls.
Not sure what it does exactly, it seems to delete one correct entry and 2 wrong ones.
All I want is no trace of those patterns in my search history,
but histdel('/', '\\s\\+\$') wouldn't be a solution since I still want this pattern in my history if I enter it manually at some point.
Any help appreciated.
" Squeeze empty lines
function! s:Squeeze()
let save_cursor = getpos(".")
" empty lines at BOF|EOF
silent %substitute/\%^\_s*\n\|\_s*\%$//
" empty line clusters
silent global/^\%(\s*$\n\)\{2,}/delete
silent! %substitute/\s\+$//e
for i in range(1, 3)
call histdel('/', -1)
endfor
call setpos('.', save_cursor)
endfunction
nmap <silent> <leader>z :call <sid>Squeeze()<cr>
function! s:Squeeze()
let save_cursor = getpos(".")
" empty lines at BOF|EOF
silent %substitute/\%^\_s*\n\|\_s*\%$//
" empty line clusters
silent global/^\%(\s*$\n\)\{2,}/delete
silent! %substitute/\s\+$//e
for i in range(1, 3)
call histdel('/', -1)
endfor
call setpos('.', save_cursor)
endfunction
nmap <silent> <leader>z :call <sid>Squeeze()<cr>
Regards
Dimitar
---
GPG Key: 2048R/160C6FA8 2012-10-11 Dimitar Dimitrov (kurkale6ka) <mitkofr@yahoo.fr>
GPG Key: 2048R/160C6FA8 2012-10-11 Dimitar Dimitrov (kurkale6ka) <mitkofr@yahoo.fr>
No comments:
Post a Comment