Seanhodges (talk | contribs) (Initial revision) |
(Adjust previous/next navigation) |
||
Line 1: | Line 1: | ||
+ | {{TipProposed |
||
⚫ | |||
+ | |id=0 |
||
+ | |previous=0 |
||
+ | |next=0 |
||
+ | |created=April 28, 2008 |
||
+ | |complexity=basic |
||
+ | |author=Seanhodges |
||
+ | |version=7.0 |
||
+ | |subpage=/200804 |
||
+ | |category1= |
||
+ | |category2= |
||
+ | }} |
||
⚫ | |||
− | <pre> |
+ | <pre> |
+ | _vim_ctags() { |
||
local cur prev |
local cur prev |
||
Line 16: | Line 29: | ||
fi |
fi |
||
− | # Escape slashes to avoid confusing awk |
+ | # Escape slashes to avoid confusing awk |
cur=${cur////\\/} |
cur=${cur////\\/} |
||
COMPREPLY=( $(compgen -W "`awk -vORS=" " "/^${cur}/ { print \\$1 }" tags`" ) ) |
COMPREPLY=( $(compgen -W "`awk -vORS=" " "/^${cur}/ { print \\$1 }" tags`" ) ) |
||
;; |
;; |
||
− | *) |
+ | *) |
_filedir_xspec |
_filedir_xspec |
||
;; |
;; |
||
− | esac |
+ | esac |
} |
} |
||
Line 30: | Line 43: | ||
excludelist='*.@(o|O|so|SO|so.!(conf)|SO.!(CONF)|a|A|rpm|RPM|deb|DEB|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MP?(E)G|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' |
excludelist='*.@(o|O|so|SO|so.!(conf)|SO.!(CONF)|a|A|rpm|RPM|deb|DEB|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MP?(E)G|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' |
||
− | complete -F _vim_ctags -f -X "${excludelist}" vi vim gvim rvim view rview rgvim rgview gview |
+ | complete -F _vim_ctags -f -X "${excludelist}" vi vim gvim rvim view rview rgvim rgview gview |
+ | </pre> |
||
− | |||
Once you restart your bash session (or create a new one) you can type: |
Once you restart your bash session (or create a new one) you can type: |
||
+ | <pre> |
||
− | + | ~$ vim -t MyC<tab key> |
|
− | |||
+ | </pre> |
||
and it will auto-complete the tag the same way it does for files and directories: |
and it will auto-complete the tag the same way it does for files and directories: |
||
+ | <pre> |
||
− | + | MyClass MyClassFactory |
|
− | + | ~$ vim -t MyC |
|
+ | </pre> |
||
⚫ | |||
+ | ==Comments== |
||
⚫ |
Revision as of 12:27, 29 April 2008
Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).
created April 28, 2008 · complexity basic · author Seanhodges · version 7.0
Add the following to your ~/.bash_completion file (create it if it does not exist):
_vim_ctags() { local cur prev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case "${prev}" in -t) # Avoid the complaint message when no tags file exists if [ ! -r ./tags ] then return fi # Escape slashes to avoid confusing awk cur=${cur////\\/} COMPREPLY=( $(compgen -W "`awk -vORS=" " "/^${cur}/ { print \\$1 }" tags`" ) ) ;; *) _filedir_xspec ;; esac } # Files matching this pattern are excluded excludelist='*.@(o|O|so|SO|so.!(conf)|SO.!(CONF)|a|A|rpm|RPM|deb|DEB|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MP?(E)G|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' complete -F _vim_ctags -f -X "${excludelist}" vi vim gvim rvim view rview rgvim rgview gview
Once you restart your bash session (or create a new one) you can type:
~$ vim -t MyC<tab key>
and it will auto-complete the tag the same way it does for files and directories:
MyClass MyClassFactory ~$ vim -t MyC
I find this really useful when I'm jumping into a quick bug fix.