📜 ⬆️ ⬇️

How vim eclipse won (walk by functions as in eclipse)

It all started with the fact that eclipse + pdt began to eat up a lot of my working time, finishing the last meters of two-hectare operatives of my laptop. If you know, dear habra people, at this point about what kind of laptop is in question, you would also have seemed my choice obvious. But to my disappointment, TextMate was not worth the fifty bucks they were asking for. Do not judge strictly! One of the main criteria for me was the ability to run from calls to function declarations ... in our project this is a very useful function :) So in the textmate book for this I did not find even hints, and my closest associate for the morning said that textmate is all same editor, but enough about textmate - about him a little more at the end. And since I am still * nix-oid with experience - the first free alternative was *** VIM *** tada !!!


I picked up my old vim links, revised my old .vimrc, written a year ago based on allaboutvim . But the main criterion still remained behind eclipse :( But literally reading the thoughts of Chaos_Code, in the days of my active return to vim, writes a wonderful article on vim . From the article I learned a lot of new things :) and first of all here and here:
There is such a wonderful thing as a cscope . I didn’t dig in particular, put this plugin in ~ / .vim / plugins and took exactly that much

cd project_dir
find . -name '*.php' > ./cscope.files
cscope -b
rm ./cscope.files

after that, as the guide says, you need to open vim in the project_dir and execute
')
:cs add cscope.out

and the only thing I happened to do was add this one mapping to the .vimrc prototype for which I found here :

nmap <cf> :cs find g <cr>=expand("<cword>")<cr><cr>


And now when in your project you want to open a place where a particular function / class is defined - just press Ctl + F by hovering the cursor over the name of the function / class, in the best case you will immediately go to the line where the required is determined :) and in projects like those I work on will have a list of options ...

And that's not it :)
As I promised at the end, a little about textmate :)
This, too, as it turns out, is not so “just an editor” and of course everything in it will automatically create cscope.out for you in the project folder. But damn it vim, it’s still a true software unix way editor :) I hope someone has made life easier;)

UPD: And what is most remarkable, thanks to mkevac, there was a simpler solution to my problem:
$ cd project/
$ ctags -R

After that, the tags file appears in the project folder and by stepping on the name of the function using the g] combination, you can freely move to the place of its declaration. And as in the case with cscope (which I completely forgot earlier) you can return using Ctrl + T

Certainly, the cscope is more powerful, because it can not only do this, but also switch to the functions called by the selected and the calling functions of the selected and a little more (enter: cs - everything is well described there;)), but for a specific feature that I did not have in vim, use ctags really easier.
And also a remake - the native MacOS-ovsky ctags does not work as it is described above (and in the original below ) - I put ctags from MacPorts and everything ran as it should

Source: https://habr.com/ru/post/54470/


All Articles