sponsor Vim development Vim logo Vim Book Ad

mail_movement : Movement over email quotes with ]] etc.

 script karma  Rating 8/2, Downloaded by 1975  Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
script type
This filetype plugin provides movement commands and text objects for email

A quoted email is determined either by:
- lines prefixed with ">" (one, or multiple for nested quotes)
- an optional email separator, e.g.
-----Original Message-----
  and the standard
From: <Name>
  optionally followed by other header lines.

Move around email quotes of either:
- a certain nesting level, as determined by the current line; if the cursor is
  not on a quoted line, any nesting level will be used.
- the range of lines from the "From: <Name>" mail header up to the line
  preceding the next email separator or next mail header.

]]                      Go to [count] next start of an email quote.
][                      Go to [count] next end of an email quote.
[[                      Go to [count] previous start of an email quote.
[]                      Go to [count] previous end of an email quote.

Move to nested email quote (i.e. of a higher nesting level as the current
line; if the cursor is not on a quoted line, any nesting level will be used).

]+                      Go to [count] next start of a nested email quote.
[+                      Go to [count] previous start of a nested email quote.

aq                      "a quote" text object, select [count] email quotes, i.e.
                        - contiguous lines having at least the same as the
                          current line's nesting level
                        - one email message including the preceding mail
                          headers and optional email separator
iq                      "inner quote" text object, select [count] regions with
                        - the same nesting level
                        - the contents of an email message without the
                          preceding mail headers
install details
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
    vim mail_movement*.vmb.gz
    :so %
To uninstall, use the :RmVimball command.

The commands and text objects are only active when 'filetype' is set to
"mail". If you use Vim as an external editor for your browser or email
program, you need to make sure that the filetype is properly detected, or
manually set the filetype every time via
    :setf mail
If you want to use this plugin also for other filetypes, e.g. "txt", create a
file ftplugin/txt_movement.vim in your 'runtimepath' (usually ~/.vim) with the
following contents:
    runtime! ftplugin/mail_movement.vim

- Requires Vim 7.0 or higher.
- Requires the CountJump plugin (vimscript #3130), version 1.40.

For a permanent configuration, put the following commands into your vimrc:

To change the default motion mapping, use:
    let g:mail_movement_BeginMapping = ''
    let g:mail_movement_EndMapping = ''
    let g:mail_movement_NestedMapping = '+'
To also change the [ / ] prefix to something else, follow the instructions for

To change the default text object mappings, use:
    let g:mail_movement_QuoteTextObject = 'q'
To also change the i prefix to something else, follow the instructions for

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
mail_movement-1.55.vmb.gz 1.55 2014-07-22 7.0 Ingo Karkat - Allow to reconfigure the mappings for the motion and text objects.
- Extract functions into separate autoload script.
mail_movement-1.54.vmb.gz 1.54 2013-06-05 7.0 Ingo Karkat Avoid use of s:function() by using autoload function name. This fixes a regression in Vim 7.3.1032, reported by lilydjwg.
mail_movement.vba.gz 1.53 2011-06-13 7.0 Ingo Karkat FIX: Directly ring the bell to avoid problems when running under :silent!.
mail_movement.vba.gz 1.52 2010-12-20 7.0 Ingo Karkat Adapted to CountJump#Region#JumpToNextRegion() again returning jump position in version 1.40.
mail_movement.vba.gz 1.51 2010-12-20 7.0 Ingo Karkat - ENH: ][ mapping in operator-pending and visual mode now also operates over / select the last line of the quote. This is what the user expects.
- Adapted to changed interface of CountJump.vim; now requires version 1.30.
mail_movement.vba.gz 1.00 2010-08-03 7.0 Ingo Karkat 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.