Set variable scope in vim functions
This commit is contained in:
parent
d68ac2dcbc
commit
236c45cd17
36
vimrc
36
vimrc
|
@ -263,21 +263,21 @@ function! GlobalReplaceIt(confirm_replacement)
|
||||||
" let term = @/
|
" let term = @/
|
||||||
" if empty(term)
|
" if empty(term)
|
||||||
call inputsave()
|
call inputsave()
|
||||||
let term = input('Enter search term: ')
|
let l:term = input('Enter search term: ')
|
||||||
call inputrestore()
|
call inputrestore()
|
||||||
" else
|
" else
|
||||||
" echo '\nReplacing '.term
|
" echo '\nReplacing '.term
|
||||||
" endif
|
" endif
|
||||||
call inputsave()
|
call inputsave()
|
||||||
let replacement = input('Enter replacement: ')
|
let l:replacement = input('Enter replacement: ')
|
||||||
call inputrestore()
|
call inputrestore()
|
||||||
if a:confirm_replacement
|
if a:confirm_replacement
|
||||||
let confirm_opt = 'c'
|
let l:confirm_opt = 'c'
|
||||||
else
|
else
|
||||||
let confirm_opt = 'e'
|
let l:confirm_opt = 'e'
|
||||||
endif
|
endif
|
||||||
execute 'Ggrep '.term
|
execute 'Ggrep '.l:term
|
||||||
execute 'Qargs | argdo %s/'.term.'/'.replacement.'/g'.confirm_opt.' | update'
|
execute 'Qargs | argdo %s/'.l:term.'/'.l:replacement.'/g'.l:confirm_opt.' | update'
|
||||||
else
|
else
|
||||||
echo "Unable to search since you're not in a git repo"
|
echo "Unable to search since you're not in a git repo"
|
||||||
endif
|
endif
|
||||||
|
@ -286,9 +286,9 @@ map <leader>gg :call GlobalReplaceIt(0)<cr>
|
||||||
map <leader>gr :call GlobalReplaceIt(1)<cr>
|
map <leader>gr :call GlobalReplaceIt(1)<cr>
|
||||||
|
|
||||||
function! Search()
|
function! Search()
|
||||||
let term = input('Grep search term: ')
|
let l:term = input('Grep search term: ')
|
||||||
if term != ''
|
if l:term != ''
|
||||||
exec 'Ag "' . term . '"'
|
exec 'Ag "' . l:term . '"'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
map <leader>s :call Search()<cr>
|
map <leader>s :call Search()<cr>
|
||||||
|
@ -387,8 +387,8 @@ nnoremap <leader><leader> <c-^>
|
||||||
" MULTIPURPOSE TAB KEY
|
" MULTIPURPOSE TAB KEY
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
function! InsertTabWrapper()
|
function! InsertTabWrapper()
|
||||||
let col = col('.') - 1
|
let l:col = col('.') - 1
|
||||||
if !col || getline('.')[col - 1] !~ '\k'
|
if !l:col || getline('.')[l:col - 1] !~ '\k'
|
||||||
return "\<tab>"
|
return "\<tab>"
|
||||||
else
|
else
|
||||||
return "\<c-p>"
|
return "\<c-p>"
|
||||||
|
@ -401,11 +401,11 @@ inoremap <s-tab> <c-n>
|
||||||
" RENAME CURRENT FILE
|
" RENAME CURRENT FILE
|
||||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
function! RenameFile()
|
function! RenameFile()
|
||||||
let old_name = expand('%')
|
let l:old_name = expand('%')
|
||||||
let new_name = input('New file name: ', expand('%'), 'file')
|
let l:new_name = input('New file name: ', expand('%'), 'file')
|
||||||
if new_name != '' && new_name != old_name
|
if l:new_name != '' && l:new_name != l:old_name
|
||||||
exec ':saveas ' . new_name
|
exec ':saveas ' . l:new_name
|
||||||
exec ':silent !rm ' . old_name
|
exec ':silent !rm ' . l:old_name
|
||||||
redraw!
|
redraw!
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -438,7 +438,7 @@ nnoremap <leader>pp :silent !open -a Marked.app '%:p'<cr>
|
||||||
" command. See usage below.
|
" command. See usage below.
|
||||||
function! SelectaCommand(choice_command, selecta_args, vim_command)
|
function! SelectaCommand(choice_command, selecta_args, vim_command)
|
||||||
try
|
try
|
||||||
let selection = system(a:choice_command . " | selecta " . a:selecta_args)
|
let l:selection = system(a:choice_command . " | selecta " . a:selecta_args)
|
||||||
catch /Vim:Interrupt/
|
catch /Vim:Interrupt/
|
||||||
" Swallow the ^C so that the redraw below happens; otherwise there will be
|
" Swallow the ^C so that the redraw below happens; otherwise there will be
|
||||||
" leftovers from selecta on the screen
|
" leftovers from selecta on the screen
|
||||||
|
@ -446,7 +446,7 @@ function! SelectaCommand(choice_command, selecta_args, vim_command)
|
||||||
return
|
return
|
||||||
endtry
|
endtry
|
||||||
redraw!
|
redraw!
|
||||||
exec a:vim_command . " " . selection
|
exec a:vim_command . " " . l:selection
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Find all files in all non-dot directories starting in the working directory.
|
" Find all files in all non-dot directories starting in the working directory.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user