I installed a vimscript written by expert in this question.
But there is one problem in the script. When I restart the computer, the bookmarks saved by the script will disappear.
Is it possible to store the bookmarks to another file (e.g. mybookmarks.txt) instead of .viminfo file? Bookmarks stored in .viminfo disappear unpredictably.
Yes. Use the 'viminfo n' option.
From :he 'viminfo':
Name of the viminfo file. The name must immediately follow
the 'n'. Must be the last one! If the "-i" argument was
given when starting Vim, that file name overrides the one
given here with 'viminfo'. Environment variables are expanded
when opening the file, not when setting the option.
Since it seems like a good tool in general, I extracted it to a plugin: http://www.vim.org/scripts/script.php?script_id=3826. This would store bookmarks only, regardless of viminfo settings, in ~/.vim_bookmarks. The filename is configurable by changing g:simple_bookmarks_filename.
Since it's a full blown plugin now, you can send bug reports on the issue tracker, so if it's not working quite right, let me know.
Cheers.
Related
There is a lot of documentation about vim's quickfix but I would like to know:
How I can I use a text file (or copy+paste from a terminal), and put this into a quick-fix list in vim?
All the docs I found so far assume that you run make or vimgrep, but in this case I just want to use a text file created elsewhere.
You're looking for :cfile / :cgetfile:
:cf[ile][!] [errorfile] Read the error file and jump to the first error.
The file you're reading naturally must be in a format that can be parsed by the 'errorformat' option.
One way to do it is to change makeprog to cat from your text file, pretty sure there's a better way to do it though.
NERDTree keeps list of all bookmark in $HOME/.NERDTreeBookmarks file .When I hit B it show all entries from that file.So I tried having a local copy of this file with project specific bookmark but this does not work :(
Is there a way to see only project related bookmark in NERDTree ?
Here's what I use for git repo specific NERDTree bookmarks.
if isdirectory(expand(".git"))
let g:NERDTreeBookmarksFile = '.git/.nerdtree-bookmarks'
endif
Since there's no way to tell how a project directory is structured, it seems like the use of a shell environment variable is the easiest solution.
First, add path to your bookmarks:
export NERDTREE_BOOKMARKS="/full/path/.NERDTreeBookmarks"
Then add this to your ~/.vimrc or similar:
if !empty($NERDTREE_BOOKMARKS)
if filereadable($NERDTREE_BOOKMARKS)
let g:NERDTreeBookmarksFile = $NERDTREE_BOOKMARKS
endif
endif
Depending on how you develop, the use of environment variables may or may not be a suitable solution. I.e. if you open/close your shell all the time, or have a multitude of shells open at once.
A simpler alternative could be something like this, but it'll only work if you open vim/a file with vim in the directory the bookmarks are located.
if filereadable(".NERDTreeBookmarks")
let g:NERDTreeBookmarksFile = ".NERDTreeBookmarks"
endif
As timss already pointed out, the key setting is the g:NERDTreeBookmarksFile config variable. You need to find a way to manipulate that (global) setting depending on the project that is currently open. Using external environment variables is one solution; I would rather solve this with one of the local vimrc plugins that are available on vim.org; I use localrc.vim - Enable configuration file of each directory myself.
In each different project dir, you create a .local.vimrc script that sets the above variable to the project's bookmark file. (This only works reliably when you only ever open one project at a time in Vim.)
I started using AutoComplPop for automatic code completions. It works great on the single file I am editing, but if file1 is making a reference to a method defined in file2, it doesn't find it.
The docs don't specify if there is a way to make it search a whole project directory, or even just all open buffers, so I can't tell if this is simply not something the plugin does, or if I need to enable something.
I was testing it out on two Ruby files, if that's relevant. Thanks!
Looks like that the cause of the problem is that ACP set the complete option for its purposes to .,w,b,k (see line #125 in autocomplpop/plugin/acp.vim),
call l9#defineVariableDefault('g:acp_completeOption', '.,w,b,k')
while the default value that is used when pressing \<C-n> is .,w,b,u,t,i. And it appears that the very last letter i actually makes the difference: for some reason vim would not use word from an include file opened in a buffer to complete words in another buffer. So, b option is not enough, i must also be included. Adding the following line into my .vimrc helped
let g:acp_completeOption = '.,w,b,u,t,i'
At least it worked for C++ files, but I'm not sure it fixes the problem for the case of Ruby scripts.
Depending on what is on the left of the cursor, ACP (like all the alternatives) decides what completion mechanism to use.
But ACP only uses Vim's default completion mechanisms: if <C-x><C-o> and <C-n>/<C-p> don't provide what you are looking for, ACP won't help. Try them out first.
Oh cool, this plugin looks a lot like neocomplcache but maybe cleaner...looks a little old. Little concerning that there are so many open tickets on that project and no updates in two years.
Anyway, according to the documentation it doesn't...really...say. Very likely its one of the following things:
Your pwd. If the root directory for your source is some/path then that should also be your current working directory. Try typing :cd some/path to see if that makes a difference.
The runtime path rtp. See if adding the directory with your source files to &rtp does the trick.
The path. Same deal as the &rtp setting.
Very likely this plugin is just falling back on the built in ruby omni completion functions bundled with vim. Try help ft-ruby-omni.
I just had the same problem, and I actually found a solution for this.
Apparently you have to set in your .vimrc file the following:
let g:acp_behaviorKeywordCommand = "\<C-x>\<C-i>"
This will make acp look in every file included by your source for completions, as if you were actually typing <C-p>. However, it is slow, after trying it I decided to revert using <C-p> when there are no matches and default behaviour in the other cases.
I'm in windows XP, and the vim TagList plugin only behaves correctly if the file I'm coding in is inside the Ctag58 folder. Otherwise it just genetats a list of my open files without tags.
I've tried adding the catalog to path and the vim command :let Tlist_Ctags_Cmd='C:\Program\Ctags58\ctags.exe'
and it didn't work but then in.
I went through the the taglist FAQ:
But the last to "dots" of part 1. of the
http://vim-taglist.sourceforge.net/faq.html
were they speak of temp and tmp variables . I can't make heads or tails of that part.
Could this be my problem? How do i tell...
Mmmm the question is not exactly clear ('it just genetats the file catalog' -- sure, that makes sense).
Without looking any further I'd suggest you add the path to the ctags.exe executable to your environment (Win+Break, advanced, environment, current user, PATH, edit, append ;C:\Program Files\Wherever\ctags\bin (of course you'd have to use the ACTUAL path not this sample).
Then you'd need to restart VIM to test it
I just ran :help registers in Vim and noticed that # 'contains the name of the alternate file'.
I have seen an example for renaming files that goes like this:
" Save the current file, foo.txt, as bar.txt
:w bar.txt
" Start editing bar.txt
:e#
So apparently in that case, the file you just saved out is the "alternate file."
Can someone give me a more general definition for the "alternate file" and what else you might use it for?
The alternate file is the file that was last edited in the current window. Actually when you use some command to open a new buffer, if the buffer that was displayed had a filename associated with it, that filename is recorded as alternate file name.
See :help alternate-file.
Very useful for...
Pasting in the name of a file I've just been looking at into the current file.
You can use <C-R># for this in insert mode or "#p in normal mode.
Not that useful for...
Jumping back and forth between two files. It does the job very well, but this is just something I don't generally need to do.
Even in the example given, I'd probably use:saveas bar.txt instead.
An Example:
Say if you're doing a bit of C programming and want to call some function. You can't remember the name of the function, so you place a mark on your current location mA and jump into several different files using tags or grep to find out where the function is declared and what it's actually called.
Ah - found it. You can copy the name and return to the mark yiw'A
Uh-oh - we also need to #include the file! Easy - just use the alternate file name register to paste the file name in... Gi#include"<C-R>#"
Be pleased that you've avoided the distraction of having to go back to the function's declaration and copy out the file name via :let #"=#% or something similar.
What I'd rather do when jumping between files:
When editing two files, it's probably easier to split them, so you can keep both on screen at the same time. If I'm editing 2 files I'll usually be comparing them in some way.
Usually I'm interested in 1-3 files (any more and I get confused). I'll often jump into or directly open many other files. Marking the interesting files, or traversing the jump list is usually the way to get around in this case.
If you're editing C/C++ where you're switching between a file and it's header, use a plugin! It will be much more convenient.
I use it in the buffer context to return to the last buffer that I was editing
vim foo bar
:n
:e#
will take you back to foo in that case
I 've always interpreted the "alternate file" as being the "previous file", so it is an handy way to jump back to the buffer you were editing.