Live data from Hacker News

Finding your way in vim: tags, cscope, grep and more

stolowski.blogspot.com

1–10 of 34 posts

Re: Finding your way in vim: tags, cscope, grep and more

#2
> A word of caution first: there is no perfect symbol-based navigation for programming languages such as C++ or Java in vim, as vim doesn't perform any syntax analysis of the code.

At least for Python, Vim's OmniCompletion does a reasonable job of figuring out function names:

http://vimdoc.sourceforge.net/htmldoc/version7.html#new-omni...

Re: Finding your way in vim: tags, cscope, grep and more

#3
Maybe somebody could help me to figure out how to save files properly with vim.

I made a script that opens all the files I need. I call the script with: :source scriptname.

Only problem is that the script works only if I open vim with 'vim' and not with 'sudo vim' (by the way, why is that?).

But if I open with 'vim', then it give me problem when I try to save...

Re: Finding your way in vim: tags, cscope, grep and more

#4

Maybe somebody could help me to figure out how to save files properly with vim. I made a script that opens all the files I need. I call the script with: :source scriptname. Only problem is that the script works only if I open vim with 'vim' and not with 'sudo vim' (by the way, why is that?). But if I open with 'vim', then it give me problem when I try to save...

Hmm, if the script is just a series of open commands it's weird that you are having issues as root (no errors displayed?). With problems when you save you mean that you don't have the required permissions(e.g. files owned by root or other users)?

A useful alias if you need root permissions to save:

cmap w!! w !sudo tee % >/dev/null

Re: Finding your way in vim: tags, cscope, grep and more

#7
post #6

I find VIM so difficult to get my head around. Emacs seems to make more sense.. is there any point in trying to grok VIM?

Careful, on this ground holy wars have been fought. http://en.wikipedia.org/wiki/Editor_war

The short answer: if you're happy with your productivity in Emacs, then there's likely no compelling reason for you to switch, unless you enjoy the challenge of learning a new text editor.

Re: Finding your way in vim: tags, cscope, grep and more

#8

Maybe somebody could help me to figure out how to save files properly with vim. I made a script that opens all the files I need. I call the script with: :source scriptname. Only problem is that the script works only if I open vim with 'vim' and not with 'sudo vim' (by the way, why is that?). But if I open with 'vim', then it give me problem when I try to save...

I made a script that opens all the files I need. I call the script with: :source scriptname.

Only problem is that the script works only if I open vim with 'vim' and not with 'sudo vim' (by the way, why is that?).

Based on what you've said, I'm not sure if this is an sudo issue or a vim issue. Where is scriptname, and where are the files that scriptname references? Your sudoers may be set up to replace the environment in such a way that vim looks relative to root's home directory rather than your user's home directory. You may need to copy your ~/.vim directory to ~root/.vim, if ~/.vim is where you've put scriptname and the other things it loads. Or you can move these into a system-wide path that vim searches.

Re: Finding your way in vim: tags, cscope, grep and more

#9
post #4

Maybe somebody could help me to figure out how to save files properly with vim. I made a script that opens all the files I need. I call the script with: :source scriptname. Only problem is that the script works only if I open vim with 'vim' and not with 'sudo vim' (by the way, why is that?). But if I open with 'vim', then it give me problem when I try to save...

Hmm, if the script is just a series of open commands it's weird that you are having issues as root (no errors displayed?). With problems when you save you mean that you don't have the required permissions(e.g. files owned by root or other users)? A useful alias if you need root permissions to save: cmap w!! w !sudo tee % >/dev/null

That is a very, very clever little cmap. Added to my .vimrc, thanks!

Re: Finding your way in vim: tags, cscope, grep and more

#10
post #6

I find VIM so difficult to get my head around. Emacs seems to make more sense.. is there any point in trying to grok VIM?

Speaking as a longtime vim user, not if you already grok Emacs. The one really good reason I can think of is that vi is pretty much ubiquitous on *nix and might be better suited if you need a powerful editor which you can almost always expect to be there for you even over ssh.
Post reply on HN