I use and love Tim Pope's excellent Fugitive plugin for VIM, I've always wanted the ability to load up a diff of all of the files in the :Glog quickfix and cycles through them to the file in HEAD (or maybe any revision!) individually. Using :diffthis doesn't persist the diff when I switch to previous versions and macros seem like a kindof off way to solve it.
Is there a canonical way to do this?
Unfortunately, there is currently no way to do this; There are a lot of ways you could make the process relatively painless, and I could definitely script it for you, except for one thing; when you unload the buffer of a fugitive-revision in diff mode, fugitive bends over backwards (tpope's own words) to stop the diff in the original file for you.
I really like the behaviour you're proposing, so I went ahead and submitted an issue to the project on GitHub. Tpope willing, this will be addressed soon, and I'll be more than happy to post a script that will completely automate this behaviour then.
Related
I make heavy uses of folds in my VIMRC file (init.vim since I'm on neovim), and I also make use of the tool fugitive.vim.
When I want to do a diff on it, it changes to the fold method to diff. Pretty useful in the moment. But when I want to go back to my previous folds I find them all gone (set foldmethod=manual) and then have to refold everything. How can I revert back to my manual folds after fugitive does a diff on them?
I've tried going through the help files and to look online but I cannot find out how to do it.
:h fold-manual mentions :mkview and :loadview, which can save the folds and then restore them.
Before set foldmethod=syntax, my vim works like rocket, but everything changed after that, my vim works like tortoise, I can't bear the vim responding time.
so, I decided set foldmethod=indent, but it's not strong and smart enough.
And I try to write some vimscript, but it worths too much, what should I do?
NOTE: I just want to fold my c++ code.
It's hard to tell what's causing this without the problematic source code files. A lot of developers use Vim to edit C++ files (with syntax-based folding), so it's not a general problem. Do you have overly long files, a lot of nesting, or many #ifdefs?
I'm a bit surprised that it's just the folding part of the syntax that slows you down. Usually, it's the whole syntax parsing (on complex files), and only :syntax off can remedy that.
You may want to fiddle with the syntax sync options (:help :syn-sync). Also read :help :syntime; this can help with troubleshooting. I'm afraid there's no quick and easy fix.
A bit old thread, but just in case, try the FastFold plugin, I've been having issues with a large PHP file, and after switching to this plugin my Vim is really snappy. And even other issues with some plugins like Quickjump seem to be gone.
Tip found in this reddit thread
Sometimes I hit the wrong keys on my laptop's small keyboard, and odd navigation or editing occurs (sometimes a feature that's new to me).
Although I can undo the editing (u) or navigation (control-o), I don't know what I did wrong, so it's difficult to avoid it in future. It's also frustrating to not know what just happened. So, I would like to be able to see my last few keystrokes.
A bit like :set showcmd, but to show the literal keystrokes, and (ideally) a short history of them.
I've only found commandline and navigation history in help/google.
To clarify: I'm not looking for commandline history, but keystroke history. e.g. did I press ) accidentally and go to the next sentence? Did I press dd and delete a line? I guess it's similar to a keystroke logger.
Commandline history (:history) only shows commands entered at the : prompt.
A bit old, but I've just found this on reddit:
You can start vim with the -w flag to write all keystrokes in a file. See :h -w
vim -w filename
To my knowledge, the closest you can get is the q command, which records your keystrokes into a register of your choice. Obviously, that has to be set up a priori as it's intended for complex repeats, although you could probably hack something to start recording on every file open. There's the matter of memory usage and that annoying "recording" prompt though.
Probably the most straightforward way would be to install keylogging software. I don't have any personal experience with these, but the security implications are probably mild if you get it from a trustworthy source or build it yourself, set it to only log to memory not a disk, only have a buffer the size of a sentence or so, or only log for vim windows.
More recently I came across a logging plugin for Vim and it reminded me of this question:
http://wolever.net/~wolever/wiki/vim-logging
It basically records everything you do for later analysis, it was intended for getting statistics about command usage but should work perfectly for finding what those magic commands you accidentally entered were.
:history will show your command history - that should help you uncover the new features that we all uncover in vim with misplaced keystrokes.
Gundo - Is probably worth a look, whilst perhaps not exactly what you are looking it will help slightly.
It lets you visualise the Vim undo tree, this means you will be able to see the last edits that happened. For example if you accidentally deleted a line or some such this will show up in the tree, however, it doesn't show you the actual keystrokes that were pushed and will not show things such as cursor movements.
Like most of you, I work in several source files of code every day. A lot of the time, my insane work flow has me doing stuff like:
# TODO
# clean up this code
# do something else with this code
Is there currently a vim plugin available that will search for TODO or a similar mnemonic and print a list of my current tasks that are on-going and in what source file it needs to be done? It would be a huge time saver instead of using grep constantly. Also with vim ctags, you can jump right in the code where you left the TODO off at.
I've not tried it (yet), but this plugin looks promising.
Edit: I've just tried this plugin out. I will be keeping it around. It's very handy and interactively moves you around the buffer while you navigate the task list.
Also, there is a mirror on github if you use pathogen or another means of git submodules for your vim directory.
When you say grep, are you talking about grep from the command line, or :grep in vim? The latter allows you to view a quickfix list of matches and jump to them. If typing out :grep TODO -r . becomes cumbersome you could easily map that operation to a hotkey.
What are some options for getting really fast 'Find in Files' searching in VIM?
Our codebase is large enough that searching needs to work off an index. grep/vimgrep/etc are too slow.
Indexing doesn't need to be particularly fast; I can index overnight.
Thanks,
[EDIT] I'm also working in a Windows environment.
If it's source code (rather than full text search), then ctags with the TagList plugin should work well for your needs. See, for example:
http://www.thegeekstuff.com/2009/04/ctags-taglist-vi-vim-editor-as-sourece-code-browser/
EDIT: TagList and ctags will work on Windows as well (that's what I use). See the TagList install page and FAQ. The following links might prove useful:
http://www.vim.org/scripts/script.php?script_id=273
http://vim-taglist.sourceforge.net/installation.html
http://vim-taglist.sourceforge.net/faq.html
There's also a TagList forum where you can get further help:
http://tech.groups.yahoo.com/group/taglist/
I set it up on my windows machine a while back, but I don't remember encountering any problems.
Something that I use, but not through vim, is ack: http://betterthangrep.com/
It is a perl based tool, and it should be usable in Windows.
If you're working with a large codebase, then it might be time to look for a more powerful solution than conventional tools. OpenGrok is a very fast source code search and cross-reference engine. On top of its great performance, it integrates with Subversion, Mercurial, and ClearCase, among other source revision control software. It sounds a lot like something you could use.
If you want support to use OpenGrok from within Vim, you could easily write a vim function that would call system() to start the search for you. To read more about writing new vim commands, look up :help 40.2 within vim.
I hope that's what you were looking for.
I don't know how I found this, but looks like someone has written a plugin for google desktop
Try to install https://github.com/mileszs/ack.vim, http://beyondgrep.com/ ,
then make a link
ln -s /usr/bin/ack-grep /usr/bin/ack
and add
noremap <C-f> :copen<CR>:Ack -aQi --ignore-dir someignoringdir
to your .vimrc, after you can find in files through Ctrl+F, enjoy
_ /|
\'o.O'
=(___)=
U
You can try this
:vimgrep /something/ */
and dont forget to open search result window after
:cw