Question: While sending email with attachments I occasionally forget to attach the relevant files.

How do I setup [mutt](http://mutt.org/) and [vim](https://www.vim.org/) to prompt me to attach missing files?

Answer: 
There's config option **abort\_noattach** for mutt and neomutt to ask You about missing attachment before sending the message if message body matches regular expression set by **abort\_noattach\_regexp**. In neomutt the option is called **abort\_noattach\_regex** without the trailing *p*. But the mutt config variant should work also because it's a config synonym - see the [code](https://github.com/neomutt/neomutt/blob/0b8cf5d/send/config.c#L276).

You can find more about this in muttrc(5) or neomuttrc(5) manpages.

Mutt
----

> 
> 3.1. [abort\_noattach](http://www.mutt.org/doc/manual/#abort-noattach)  
> 
> Type: quadoption  
> 
> Default: no
> 
> 
> When the body of the message matches $abort\_noattach\_regexp and there are no attachments, this quadoption controls whether to abort sending the message.
> 
> 
> 

> 
> 3.2. [abort\_noattach\_regexp](http://www.mutt.org/doc/manual/#abort-noattach-regexp)  
> 
> Type: regular expression  
> 
> Default: “attach”
> 
> 
> Specifies a regular expression to match against the body of the message, to determine if an attachment was mentioned but mistakenly forgotten. If it matches, $abort\_noattach will be consulted to determine if message sending will be aborted.
> 
> 
> Like other regular expressions in Mutt, the search is case sensitive if the pattern contains at least one upper case letter, and case insensitive otherwise.
> 
> 
> 

Neomutt
-------

> 
> 3.3. [abort\_noattach](https://neomutt.org/guide/reference#3-3-%C2%A0abort_noattach)  
> 
> Type: quadoption  
> 
> Default: no
> 
> 
> If set to yes , when composing messages containing the regular expression specified by $abort\_noattach\_regex and no attachments are given, composition will be aborted. If set to no , composing messages as such will never be aborted.
> 
> 
> Example:
> 
> 
> set abort\_noattach\_regex = "\<attach(|ed|ments?)\>"
> 
> 
> 

> 
> 3.4. [abort\_noattach\_regex](https://neomutt.org/guide/reference#3-4-%C2%A0abort_noattach_regex)  
> 
> Type: regular expression  
> 
> Default: “ <(attach|attached|attachments?)> ”
> 
> 
> Specifies a regular expression to match against the body of the message, to determine if an attachment was mentioned but mistakenly forgotten. If it matches, $abort\_noattach will be consulted to determine if message sending will be aborted.
> 
> 
> Like other regular expressions in NeoMutt, the search is case sensitive if the pattern contains at least one upper case letter, and case insensitive otherwise.
> 
> 
>
The [CheckAttach](https://github.com/chrisbra/CheckAttach) vim plugin by [Christian Brabandt](http://blog.256bit.org) will check for keywords in mail messages and ask you to attach the files. The plugin will not consider the quoted parts of mail messages.

The plugin will highlight the keyword(s) and prompt you for the
files to attach, when you save your mail.

Which looks like this:

```
Attach file: (leave empty to abort):

```

At that prompt you can specify any file you'd like to attach. It allows
filename completion, so you can use `<Tab>` to let vim complete file paths.
Additionally you can specify glob patterns and let vim attach all files, that
match the pattern. If you enter an empty value or "n" (without
the quotes), then no file will be attached.

**Installation:**

Get the most recent [plugin package from the vim site](https://www.vim.org/scripts/script.php?script_id=2796).

Then at a command prompt run,

```
vim CheckAttach-0.17.vmb

```

and source the vimscript:

```
:so %

```

It is also possible to check the code out from [GitHub](https://github.com/chrisbra/CheckAttach).

**Configuration:**

`edit_headers` must be set in your `.muttrc`. This enables the pseudo-header `:Attach`. See muttrc man page for further information.

To specify which keywords will be searched for add the following to your `.vimrc`:

```
let g:attach_check_keywords = 'attached,attachment'

```

**Alternative usage:**

The plugin also defines the vim command `:AttachFile`. This allows you to
attach any number of files using a glob pattern.

To attach all png files from `~/pictures/`:

```
 :AttachFile ~/pictures/*.png

```