Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape special chars in <cword> when run :Ack<CR> #234

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion autoload/ack.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ function! ack#Ack(cmd, args) "{{{
endif

" If no pattern is provided, search for the word under the cursor
let l:grepargs = empty(a:args) ? expand("<cword>") : a:args . join(a:000, ' ')
if empty(a:args)
let l:grepargs = expand("<cword>")
" escape special chars in <cword> and wrap in '
" use " instead of ', for 'xxx' will cause no effect on windows
let l:grepargs = '"' . escape(l:grepargs, '$') . '"'
else
let l:grepargs = a:args . join(a:000, ' ')
endif

"Bypass search if cursor is on blank string
if l:grepargs == ""
Expand Down