Switching buffers on write...

15 views
Skip to first unread message

Sonny Chee

unread,
Oct 8, 2015, 1:34:02 PM10/8/15
to vim_use
Hey Guys,

I suspect this question has been asked and answered before but I haven't found any relevant answers.

I would like to map the command:

:w new_filename

to do the following two things

:w new_filename
:e new_filename

I thought I would implement this with an autocmd on the BufFilePost event. My challenge is how to access the new_file_name value. I checked the help docs on registers but didn't see anything relevant there....

Tim Chase

unread,
Oct 8, 2015, 1:57:34 PM10/8/15
to vim...@googlegroups.com
On 2015-10-08 10:34, Sonny Chee wrote:
> I would like to map the command:
>
> :w new_filename
>
> to do the following two things
>
> :w new_filename
> :e new_filename

Is there a reason not to use ":saveas" which does just that (without
losing your undo history, jump-lists, folds, etc)?

-tim





Sonny

unread,
Oct 8, 2015, 2:31:25 PM10/8/15
to vim...@googlegroups.com
Only ignorance... thanks, that works better.






--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/b0CMyZ4FQGU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Sonny.
----------------------------------------------------------------------------
Be true to your work, your word, and your friend. Henry David Thoreau.

Tim Chase

unread,
Oct 8, 2015, 2:37:26 PM10/8/15
to vim...@googlegroups.com
On 2015-10-08 11:30, Sonny wrote:
> Only ignorance... thanks, that works better.

Cool. I know that sometimes folks know about things but just want a
fast/easy way to get to it. In this case, ":sav" might be more
characters than you want to type if you do it regularly, so I didn't
know if you wanted some sort of ":command" created to make it
shorter. Glad vim met your needs :-)

-tim


Reply all
Reply to author
Forward
0 new messages