mirror of
https://github.com/amix/vimrc
synced 2025-06-30 20:05:01 +08:00
Updated all plugins that are non-forked. Added some new plugins.
Added update_plugins.py which can fetch new plugins from GitHub. New plugins added: zencoding, vim-indent-object, taglist, nginx.vim
This commit is contained in:
@ -18,9 +18,13 @@ Install on Debian / Ubuntu with:
|
||||
|
||||
sudo apt-get install ack-grep
|
||||
|
||||
For Debian / Ubuntu you can add this line into your .vimrc:
|
||||
Install on Fedora with:
|
||||
|
||||
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
|
||||
su -l -c 'yum install ack'
|
||||
|
||||
Install on openSUSE with:
|
||||
|
||||
sudo zypper install ack
|
||||
|
||||
Install on Gentoo with:
|
||||
|
||||
@ -34,10 +38,18 @@ Install with MacPorts:
|
||||
|
||||
sudo port install p5-app-ack
|
||||
|
||||
Install with Gentoo Prefix
|
||||
Install with Gentoo Prefix:
|
||||
|
||||
emerge ack
|
||||
|
||||
Install on FreeBSD with:
|
||||
|
||||
cd /usr/ports/textproc/p5-ack/ && make install clean
|
||||
|
||||
You can specify a custom ack name and path in your .vimrc like so:
|
||||
|
||||
let g:ackprg="<custom-ack-path-goes-here> -H --nocolor --nogroup --column"
|
||||
|
||||
Otherwise, you are on your own.
|
||||
|
||||
### The Plugin
|
||||
@ -75,6 +87,10 @@ Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use `:Ac
|
||||
|
||||
See ack --help=types for a list of valid types.
|
||||
|
||||
### Gotchas ###
|
||||
|
||||
Some characters have special meaning, and need to be escaped your search pattern. For instance, '#'. You have to escape it like this `:Ack '\\\#define foo'` to search for `#define foo`. (From [blueyed in issue #5](https://github.com/mileszs/ack.vim/issues/5).)
|
||||
|
||||
### Keyboard Shortcuts ###
|
||||
|
||||
In the quickfix window, you can use:
|
||||
@ -83,6 +99,8 @@ In the quickfix window, you can use:
|
||||
go to preview file (open but maintain focus on ack.vim results)
|
||||
t to open in new tab
|
||||
T to open in new tab silently
|
||||
h to open in horizontal split
|
||||
H to open in horizontal split silently
|
||||
v to open in vertical split
|
||||
gv to open in vertical split silently
|
||||
q to close the quickfix window
|
||||
|
@ -43,6 +43,16 @@ shows the results in a split window.
|
||||
directory) for filenames matching the {pattern}. Behaves just like the
|
||||
|:grep| command, but will open the |Quickfix| window for you.
|
||||
|
||||
:AckHelp[!] [options] {pattern} *:AckHelp*
|
||||
|
||||
Search vim documentation files for the {pattern}. Behaves just like the
|
||||
|:Ack| command, but searches only vim documentation .txt files
|
||||
|
||||
:LAckHelp [options] {pattern} *:LAckHelp*
|
||||
|
||||
Just like |:AckHelp| but instead of the |quickfix| list, matches are placed
|
||||
in the current |location-list|.
|
||||
|
||||
Files containing the search term will be listed in the split window, along
|
||||
with the line number of the occurrence, once for each occurrence. <Enter> on
|
||||
a line in this window will open the file, and place the cursor on the matching
|
||||
@ -63,6 +73,10 @@ t open in a new tab.
|
||||
|
||||
T open in new tab silently.
|
||||
|
||||
h open in horizontal split.
|
||||
|
||||
H open in horizontal split silently.
|
||||
|
||||
v open in vertical split.
|
||||
|
||||
gv open in vertical split silently.
|
||||
|
@ -2,74 +2,112 @@
|
||||
" in your path.
|
||||
" On Debian / Ubuntu:
|
||||
" sudo apt-get install ack-grep
|
||||
" On your vimrc:
|
||||
" let g:ackprg="ack-grep -H --nocolor --nogroup --column"
|
||||
"
|
||||
" With MacPorts:
|
||||
" sudo port install p5-app-ack
|
||||
" With Homebrew:
|
||||
" brew install ack
|
||||
|
||||
" Location of the ack utility
|
||||
if !exists("g:ackprg")
|
||||
let g:ackprg="ack -H --nocolor --nogroup --column"
|
||||
let s:ackcommand = executable('ack-grep') ? 'ack-grep' : 'ack'
|
||||
let g:ackprg=s:ackcommand." -H --nocolor --nogroup --column"
|
||||
endif
|
||||
|
||||
if !exists("g:ack_apply_qmappings")
|
||||
let g:ack_apply_qmappings = !exists("g:ack_qhandler")
|
||||
endif
|
||||
|
||||
if !exists("g:ack_apply_lmappings")
|
||||
let g:ack_apply_lmappings = !exists("g:ack_lhandler")
|
||||
endif
|
||||
|
||||
if !exists("g:ack_qhandler")
|
||||
let g:ack_qhandler="botright copen"
|
||||
endif
|
||||
|
||||
if !exists("g:ack_lhandler")
|
||||
let g:ack_lhandler="botright lopen"
|
||||
endif
|
||||
|
||||
function! s:Ack(cmd, args)
|
||||
redraw
|
||||
echo "Searching ..."
|
||||
redraw
|
||||
echo "Searching ..."
|
||||
|
||||
" If no pattern is provided, search for the word under the cursor
|
||||
if empty(a:args)
|
||||
let l:grepargs = expand("<cword>")
|
||||
else
|
||||
let l:grepargs = a:args
|
||||
end
|
||||
" If no pattern is provided, search for the word under the cursor
|
||||
if empty(a:args)
|
||||
let l:grepargs = expand("<cword>")
|
||||
else
|
||||
let l:grepargs = a:args . join(a:000, ' ')
|
||||
end
|
||||
|
||||
" Format, used to manage column jump
|
||||
if a:cmd =~# '-g$'
|
||||
let g:ackformat="%f"
|
||||
else
|
||||
let g:ackformat="%f:%l:%c:%m"
|
||||
end
|
||||
" Format, used to manage column jump
|
||||
if a:cmd =~# '-g$'
|
||||
let g:ackformat="%f"
|
||||
else
|
||||
let g:ackformat="%f:%l:%c:%m"
|
||||
end
|
||||
|
||||
let grepprg_bak=&grepprg
|
||||
let grepformat_bak=&grepformat
|
||||
try
|
||||
let &grepprg=g:ackprg
|
||||
let &grepformat=g:ackformat
|
||||
silent execute a:cmd . " " . l:grepargs
|
||||
finally
|
||||
let &grepprg=grepprg_bak
|
||||
let &grepformat=grepformat_bak
|
||||
endtry
|
||||
let grepprg_bak=&grepprg
|
||||
let grepformat_bak=&grepformat
|
||||
try
|
||||
let &grepprg=g:ackprg
|
||||
let &grepformat=g:ackformat
|
||||
silent execute a:cmd . " " . escape(l:grepargs, '|')
|
||||
finally
|
||||
let &grepprg=grepprg_bak
|
||||
let &grepformat=grepformat_bak
|
||||
endtry
|
||||
|
||||
if a:cmd =~# '^l'
|
||||
botright lopen
|
||||
else
|
||||
botright copen
|
||||
endif
|
||||
if a:cmd =~# '^l'
|
||||
exe g:ack_lhandler
|
||||
let l:apply_mappings = g:ack_apply_lmappings
|
||||
else
|
||||
exe g:ack_qhandler
|
||||
let l:apply_mappings = g:ack_apply_qmappings
|
||||
endif
|
||||
|
||||
if l:apply_mappings
|
||||
exec "nnoremap <silent> <buffer> q :ccl<CR>"
|
||||
exec "nnoremap <silent> <buffer> t <C-W><CR><C-W>T"
|
||||
exec "nnoremap <silent> <buffer> T <C-W><CR><C-W>TgT<C-W><C-W>"
|
||||
exec "nnoremap <silent> <buffer> o <CR>"
|
||||
exec "nnoremap <silent> <buffer> go <CR><C-W><C-W>"
|
||||
exec "nnoremap <silent> <buffer> v <C-W><C-W><C-W>v<C-L><C-W><C-J><CR>"
|
||||
exec "nnoremap <silent> <buffer> gv <C-W><C-W><C-W>v<C-L><C-W><C-J><CR><C-W><C-J>"
|
||||
exec "nnoremap <silent> <buffer> h <C-W><CR><C-W>K"
|
||||
exec "nnoremap <silent> <buffer> H <C-W><CR><C-W>K<C-W>b"
|
||||
exec "nnoremap <silent> <buffer> v <C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t"
|
||||
exec "nnoremap <silent> <buffer> gv <C-W><CR><C-W>H<C-W>b<C-W>J"
|
||||
endif
|
||||
|
||||
" If highlighting is on, highlight the search keyword.
|
||||
if exists("g:ackhighlight")
|
||||
let @/=a:args
|
||||
set hlsearch
|
||||
end
|
||||
" If highlighting is on, highlight the search keyword.
|
||||
if exists("g:ackhighlight")
|
||||
let @/=a:args
|
||||
set hlsearch
|
||||
end
|
||||
|
||||
redraw!
|
||||
redraw!
|
||||
endfunction
|
||||
|
||||
function! s:AckFromSearch(cmd, args)
|
||||
let search = getreg('/')
|
||||
" translate vim regular expression to perl regular expression.
|
||||
let search = substitute(search,'\(\\<\|\\>\)','\\b','g')
|
||||
call s:Ack(a:cmd, '"' . search .'" '. a:args)
|
||||
let search = getreg('/')
|
||||
" translate vim regular expression to perl regular expression.
|
||||
let search = substitute(search,'\(\\<\|\\>\)','\\b','g')
|
||||
call s:Ack(a:cmd, '"' . search .'" '. a:args)
|
||||
endfunction
|
||||
|
||||
function! s:GetDocLocations()
|
||||
let dp = ''
|
||||
for p in split(&rtp,',')
|
||||
let p = p.'/doc/'
|
||||
if isdirectory(p)
|
||||
let dp = p.'*.txt '.dp
|
||||
endif
|
||||
endfor
|
||||
return dp
|
||||
endfunction
|
||||
|
||||
function! s:AckHelp(cmd,args)
|
||||
let args = a:args.' '.s:GetDocLocations()
|
||||
call s:Ack(a:cmd,args)
|
||||
endfunction
|
||||
|
||||
command! -bang -nargs=* -complete=file Ack call s:Ack('grep<bang>',<q-args>)
|
||||
@ -78,3 +116,5 @@ command! -bang -nargs=* -complete=file AckFromSearch call s:AckFromSearch('grep<
|
||||
command! -bang -nargs=* -complete=file LAck call s:Ack('lgrep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAckAdd call s:Ack('lgrepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFile call s:Ack('grep<bang> -g', <q-args>)
|
||||
command! -bang -nargs=* -complete=help AckHelp call s:AckHelp('grep<bang>',<q-args>)
|
||||
command! -bang -nargs=* -complete=help LAckHelp call s:AckHelp('lgrep<bang>',<q-args>)
|
||||
|
Reference in New Issue
Block a user