sponsor Vim development Vim logo Vim Book Ad

basic Tip #296: Attach the currently open file to email

 tip karma   Rating 24/19, Viewed by 1991 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   August 2, 2002 14:52      complexity:   basic
author:   hari_vim at yahoo      as of Vim:   5.7

This is very simple, but most people don't seem to take advantage of this. Often you have some file (source code or other text file) already open in an existing vim session and you need to attach it with an email. It is very simple.
    - First copy the filename into clipboard. For this I put the following mapping in vimrc and press <F2>:
         nnoremap <F2> :let @*=expand("%:p")<cr>
    - Go to your email compose window and use your regular file attachment menu (Insert->File in outlook) and press ^V (or whatever key to paste clipboard) and press Enter.

That is all there to it. If you are on windows and your email client doesn't accept forward-slashes, then you might want to change the map to:

         nnoremap <F2> :let @*=substitute(expand("%:p"), "/", "\\", "g")<cr>


 rate this tip  Life Changing Helpful Unfulfilling 

<< Line/word/file/whatever completion | Start in insert mode without loosing your escape key >>

Additional Notes

Anonymous, August 3, 2002 20:26
Very nice tip. Thanks
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge.net Logo