sponsor Vim development Vim logo Vim Book Ad

vim-mail : A plugin to ease mail redaction from vim

 script karma  Rating 0/0, Downloaded by 2274  Comments, bugs, improvements  Vim wiki

created by
David Beniamine
script type
# Readme

## What is this plugin ?

This plugin is a small helper for writing mail from vim, I designed it using
mutt but it should work with other clients. I recommend to use it in
combination with [CheckAttach](https://github.com/chrisbra/CheckAttach).

## Features

This plugin provides the following features

### Contact completion

The contact completion is designed for
[pycarddav](https://pypi.python.org/pypi/pyCardDAV), however it is possible to
use any external tools, see [address book

To search your address book from vim:

+   While writing a mail, in insert mode, type:


    or (using omnifunc)


+   While editing any other file:

    As the previous mapping are only set for mail files, you need to set the
    completefunc (using omnifunc would be a bad idea):

        set completefunc=vimmail#completion#CompleteAddr

    Then use `<C-X><C-U>` (in insert mode) to trigger contact completion.

It will search for the word under the cursor in your contact list.

If you are currently in a From,To,CC or Bcc line, only mail addresses will
be proposed, else all the match will appear. More details will appear in
the preview window including contact name, type of the entry (mail, cell,
phone etc.).

To synchronise your address book, in a mail, in normal mode, type:


### Redaction

####   Cursor initial position

By default vim-mail place your cursor at the beginning of the mail (right
after the headers) adds a blank line and switch to insert mode. This
behavior can be modified through a series of flags:

The available flags are:

Flag | Meaning
`i`  | insert mode
`o`  | Add new line after cursor
`O`  | Add new line before cursor
`A`  | Place cursor at the end of the line
`W`  | Start on second word (a.k.a first address of field / word of subject)
`t`  | top (Right after headers)
`b`  | Bottom (After last message)
`F`  | From field
`T`  | To field
`C`  | Cc field
`B`  | Bcc field
`S`  | Subject field

##### Examples

Adding the following line to your vimrc will make you start at the end of
the subject line:

    let g:VimMailStartFlags="SAi"

Or if you want to start at the end of the mail:

    let g:VimMailStartFlags="boi"

#### Easy spelllang switch

While writing mails, I often need to do switch the spell lang which can be
annoying, so this plugin provide an easy way to do it. Just type:


and the plugin will switch the spelllang using a list of allowed languages.  
If the current spellang is the last allowed, it will disable spell, hit


once more and you will restart with the first lang.
You can set the list of allowed langs in your vimrc:

    let g:VimSpellLangs=['fr', 'en', 'sp']

The default langs are french, english.

This will work for any filetype as it can be usefull for many other kind of

#### Messages folds

A folding method which allows you to open are close the messages of the
conversation is provided.

### Quick in-mail navigation

With this plugin, you can easily navigate through the different par of the
mail using the following mappings:

+   Headers

    Mapping          | Effect
    `<LocalLeader>f` | Go to the From field
    `<LocalLeader>b` | Go to the Bcc field
    `<LocalLeader>c` | Go to the Cc field
    `<LocalLeader>s` | Go to the SUbject field
    `<LocalLeader>R` | Go to the Reply-To field
    `<LocalLeader>t` | Go to the Reply-To field

+   Conversation

    Mapping          | Effect
    `<LocalLeader>B` | Go to the first line (after headers)
    `<LocalLeader>E` | Go to the first line after the conversation
    `<LocalLeader>r` | Go to the first message of the conversation
    `<LocalLeader>r2`| Go to the second message of the conversation
    `<LocalLeader>r3`| Go to the third message of the conversation
    `<LocalLeader>r4`| Go to the fourth message of the conversation
    `<LocalLeader>S` | Go to your signature

### Launch mail client

One of Mutt main drawbacks is that you can't access your mailbox while
writing mails, good news everyone, with vim-mail you can open mutt in RO
mode easily by typing


### Send file from Vim

When you are vimming at one point, you might want to send the file you are
working on. Leaving vim to send a mail from vim is so annoying, happily there
is the solution just type: `<LocalLeader>m` and VimMail will pipe the file to

## Mappings

All mappings can be disabled by adding the following line to your vimrc:

    let g:VimMailDoNotMap=1

+   On any file

    Mapping          | Effect
    `<LocalLeader>m` | Send the current buffer
    `<LocalLeader>l` | Switch spelllang
    `<LocalLeader>M` | Open the mail client

+   On mail only

    Mapping          | Effect
    `<Localleader>a` | Search the word before cursor as a contact
    `<LocalLeader>f` | Go to the From field
    `<LocalLeader>b` | Go to the Bcc field
    `<LocalLeader>c` | Go to the Cc field
    `<LocalLeader>s` | Go to the SUbject field
    `<LocalLeader>R` | Go to the Reply-To field
    `<LocalLeader>t` | Go to the Reply-To field
    `<LocalLeader>r` | Go to the first message of the conversation
    `<LocalLeader>r2`| Go to the second message of the conversation
    `<LocalLeader>r3`| Go to the third message of the conversation
    `<LocalLeader>r4`| Go to the fourth message of the conversation
    `<LocalLeader>S` | Go to your signature


### Address book configuration

It is possible to use another address book than pycard by setting the
following variables:

    let g:VimMailContactSyncCmd="my_synchronisation_cmd"
    let g:VimMailContactQueryCmd="my_query_cmd"

The only restriction is that the query command should give an output similar
to pc_query output, aka something like:

    Name: Someone
    Tel (CELL): 000000000
    EMAIL : someone@foo.bar
    Name: Someone else
    TEL: 0000000
    EMAIL (Work): Someone.else@work.com
    EMAIL (Perso): Someone.else@dummyprovider.com

The fields between parentheses are optional.

If you don't see the preview while using contact completion, add the following
to your vimrc (see |completeopt| |preview| ):

    set completeopt=preview

If you don't want this completion you can either not use the plugin or add
the following line to your vimrc:

    let g:VimMailDontUseComplete=1

By default, the contact completion appends the query to the result list, you
can disable this feature:

    let g:VimMailDoNotAppendQueryToResults

### Spell

Setting the list of possible spell langs:

    let g:VimSpellLangs=['fr', 'en', 'sp']

### Folds

To disable message folds, add the following line to your vimrc:

    let g:VimMailDoNotFold=1

### Mail Client

You can set the mail client command to your launcher script by adding to your
vimrc something like:

    let g:VimMailClient="/path/to/your/launcher"

If you are not using mutt, or want to customize the send mail command, just
add something like that to your vimrc (this is the default command):

    let g:VimMailSendCmd=":! mutt -a %"

## License

This plugin is distributed under GPL Licence v3.0, see

More infos at https://github.com/dbeniamine/vim-mail
install details
## Install

### Vizardry

If you have [Vizardry](https://github.com/dbeniamine/vizardry) installed, you
can run from vim:

    :Invoke -u dbeniamine vim-mail

### Pathogen install

    git clone https://github.com/dbeniamine/vim-mail.git ~/.vim/bundle/vim-mail

### Quick install

    git clone https://github.com/dbeniamine/vim-mail.git
    cd vim-mail/
    cp -r ./* ~/.vim

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-mail.tgz 0.2.6 2016-06-22 7.0 David Beniamine + Mapping to send current buffer by mail
+ Cleaner documentation
+ Autoload file is now splitted into three parts:
  + spelllang
  + completion
  + sendmail
vim-mail.tgz 0.2.4 2015-08-22 7.0 David Beniamine + Use autoload
+ Few minor fix
see github for more info
vim-mail.tar.gz 0.2.3 2015-05-19 7.0 David Beniamine Small corrections / swith to omni completion for better plugin integration
vim-mail.tar.gz 0.2.2 2015-03-16 7.0 David Beniamine CHG: Contact query is not bounded to pc_query anymore
ADD: contact synchronization capacity
CHG: Cleaner documentation
vim-mail.tar.gz 0.2.1 2015-03-15 7.0 David Beniamine ADD: Fold Method to open/close messages in conversation
ADD: Mapping to go at beginning/end of conversation
CHG: Cleaner doc and code
vim-mail.tar.gz 0.2 2015-03-15 7.0 David Beniamine Add: Easy mail navigation feature
CHG: Small code clarifications
CHG: Better doc
vim-mail.tar.gz 0.1 2015-03-14 7.0 David Beniamine Initial upload
ip used for rating:

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 the maillist. Help Bram help Uganda.