Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Vim has the concept of <cword> and <cWord> (you can :h <cword> these for more info), which are basically the things that vim will jump across when you press 'w' or 'W'.

You can combine this with grep and the location list to find symbol usage across multiple files.

    nnoremap <leader>g :grep <cword><CR>
You can then use :cnext and :cprev (or focusing the window and selecting an entry) to navigate between them.

As others have stated, you can also use ctags (plugins like https://github.com/ludovicchabant/vim-gutentags are useful for refreshing tags in a project), but for some languages you may need to add a tag definition (e.g. for something like rust or zig). For older languages like C you should be fine.



Worth noting that :grep can be configued to use ag, rg, ack or git grep which can add some modern conviences like respecting prohect specific ignore lists and there are plugins that build more on top for each specific tool.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: