Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code navigation in vim and emacs

The IDE feature that I miss the most in emacs and vim are code navigation and find usages. Both of these editor have the following similar features for them:

  • Tags - identifiers from specified files are indexed and when you press shortcut on a word which is an identifier, you will be navigated there
  • CScope - it allows you to navigate to "usages" of an identifier

As far as I understand, both of these systems are very imprecise. If we have similar identifiers with the same name both tags and scope might mix them up. Are there any better alternatives and how precise they really are?

like image 781
Konstantin Solomatov Avatar asked Nov 18 '12 13:11

Konstantin Solomatov


2 Answers

I use cscope and semantic in Emacs. It is just enough for me.

In cscope the two function I heavily used are cscope-find-global-definition and cscope-find-this-symbol. The previous function is quite precise.

C-c s s         Find symbol. 
C-c s d         Find global definition.

As for semantic(dynamic index, do not need to generate TAGS).

(global-set-key [f8] 'semantic-ia-fast-jump) ;; jump to definition.
(global-set-key [S-f8]                       ;; jump back
                (lambda ()
                  (interactive)
                  (if (ring-empty-p (oref semantic-mru-bookmark-ring ring))
                     (error "Semantic Bookmark ring is currently empty"))
                  (let* ((ring (oref semantic-mru-bookmark-ring ring))
                         (alist (semantic-mrub-ring-to-assoc-list ring))
                         (first (cdr (car alist))))
                    (if (semantic-equivalent-tag-p (oref first tag)
                                                   (semantic-current-tag))
                        (setq first (cdr (car (cdr alist)))))
                    (semantic-mrub-switch-tags first))))
like image 53
louxiu Avatar answered Sep 26 '22 13:09

louxiu


GNU Global, for example, allows duplicate identifiers, and you'll be able to select needed.

like image 29
Alex Ott Avatar answered Sep 23 '22 13:09

Alex Ott