Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like 'V to (almost) always open $MYVIMRC. For instance, if I do mV, I would like it to revert back when I start a new Vim instance. How would I go about setting this mark in $MYVIMRC file?

Oddly enough, adding normal mV to MYVIMRC sets a mark in ~/.viminfo at 1 0. o.O

share|improve this question

3 Answers 3

I don't think you can set a mark to a specific file via .vimrc, however you can map a command to `V so that it opens your $MYVIMRC (won't retain the specific line though)

:nnoremap `V :e $MYVIMRC<CR>

Of course you can also pick another key sequence so you don't override the normal `V behaviour.

share|improve this answer
    
Agreed. I don't think marks are the right solution for this. See :h last-position-jump for a way to restore cursor position upon opening files. –  Etan Reisner Aug 19 '13 at 14:36
    
@EtanReisner I already have `` " `` in $MYVIMRC` to open last position when restoring a file. –  kzh Aug 19 '13 at 14:40
    
Does that work? I was under the impression that was too early to be of any use (the buffers haven't been loaded yet) also that only happens once whereas the last-position-jump autocmd happens on every opened file. –  Etan Reisner Aug 19 '13 at 14:43
    
@EtanReisner what I have is the same thing at :help last-position-jump –  kzh Aug 19 '13 at 15:37
    
Also :help restore-cursor –  kzh Aug 19 '13 at 16:08

The following is the best answer that I came up with. I would be happy to accept any answer that is better or more complete (with implementation) than mine.

Have a script in $MYVIMRC that edits the ~/.viminfo file, adding the appropriate line to the #File Marks: section:

'V  1  0  ~/.vimrc
share|improve this answer

I think that you are taking the problem from the wrong end. Instead of starting with a mean and trying to make it do what you want, start with what you want and work out a solution.

If what you want is to be able to open your vimrc quickly, you should use a mapping like

nnoremap ,v :e $MYVIMRC<CR>

Which will obviously never interfere with your ability to use file marks and doesn't require to mess with your viminfo.


To answer your other question:

nnoremap ,v :vs $MYVIMRC<CR>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.