开发者

Easy way to deal with java package folders?

开发者 https://www.devze.com 2023-04-04 01:45 出处:网络
Is there an easy way to deal with the nested Java package folders on the command line?I\'m always cd-ing (with lots of tab autocomplete) through empty folders (except hidden svn files) in bash and vim

Is there an easy way to deal with the nested Java package folders on the command line? I'm always cd-ing (with lots of tab autocomplete) through empty folders (except hidden svn files) in bash and vim. 开发者_运维百科Are there any tools to make these less frustrating?

org/my/group/team/project/subpackage/TheFileIActuallyWant.java

I'm driven towards Eclipse because of this constant issue.

The worst is CDing all the way down to create a class, and then splitting a vim window with a class in other project. Yuck!


You have two choices (IMHO):

  • Use a project explorer like The NERD tree: A tree explorer plugin for navigating the filesystem
  • Install in Vim a plugin for quick searching like
    • FuzzyFinder: buffer/file/command/tag/etc explorer with fuzzy matching or
    • Command-T: Fast file navigation for VIM


If you are mostly editing files and not creating new ones, it may help to symlink all .java files into a directory called quickedit. Then you can just type vim quickedit/MyClass.java, assuming that your class names are mostly unique.


How about this?

In your .bash_profile (or equivalent) add:

function supercd() { cd $(dirname $(find "$@" -type f | head));}

then use it!

~ $ supercd temp1
~/temp1/temp2/temp3/temp4 $ ls
test.java
~/temp1/temp2/temp3/temp4 $

supercd will take you to the first directory containing a file under the directory you specify.

Undoubtedly buggy, but a good start :)


Check out AutoJump, written by fellow StackOverflow user static_rtti.


If you're using just vim you'll face this kind of problems. Remember that every directory will become a finer grained namespace. Namespaces are good! (From the Zen of Python: Namespaces are one honking great idea -- let's do more of those!).

So, I think it's a good choice to start using eclipse. I think that Java is an imposible language without an IDE.


you can try 'tree' on *nix systems


Ctags might help you.

$ ctags -f ~/.tags -R ~/myprojects/src $JAVA_HOME/src

Then tell vim to know where the tag file is. In your .vimrc:

set tags+=~/.tags

Now you can jump to declaration parts by pressing CTRL-] on any identifiers.

pressing CTRL-t to return again to the original position.

0

精彩评论

暂无评论...
验证码 换一张
取 消