[lug] vi as a Mutt editor
Matthew Snelham
infinite at sigalrm.com
Thu Sep 22 19:51:44 MDT 2005
On 22 Sep 2005 07:17 PM or thereabouts, D. Frye wrote:
> On Thu, Sep 22, 2005 at 06:11:11PM -0600, Bill Thoen wrote:
> > I'm switching from Pine to Mutt and its default editor is vi. I know I
> > can set up a different editor, but currently pico isn't installed and I
> > can't figure why emacs doesn't work. Anyway, I'm willing to try vi as a
> > mail editor, but I'd like it to do a couple of things. First, can I
> > get it wrap lines at about 68 characters or so? And does Mutt have a
> > spell checker?
>
> Since you have already gotten spell checking figured out, here is the
> other bit. I have this in my .muttrc file:
>
> set editor='vim -c "set tw=72" +2'
>
> It's in the document, but here it is anyways.
I have the following in my .muttrc file:
# Show me the goods.
set edit_headers
# use vim as editor and start after first empty line
set editor="vim -u ~/.mutt/vimrc -c ':0;/^To: '"
This way, VIM ignores your default .vimrc settings, and can behave
entirely differently when functioning as a mail editior.
I've attached my mutt vimrc file, just in case it's useful. (and if the
BLUG list allows)
--Matthew
infinite at sigalrm.com
--
"UNIX was not designed to stop you from doing stupid things,
because that would also stop you from doing clever things."
-Doug Gwyn
-------------- next part --------------
version 6.3
set noautoindent
set ic
set bf
set textwidth=75
set tabstop=8
set showmatch
set sh=/bin/bash
nmap <C-J> vipgq
nmap <C-J> gq
set autowrite
set nobackup
set backspace=2
set nocompatible
set comments=b:#,:%,fb:-,n:>,n:)
set dictionary=/usr/dict/words,/usr/local/ispell/words
set digraph
set noerrorbells
set esckeys
set noexpandtab
set helpheight=0
set hidden
set highlight=8r,db,es,hs,mb,Mr,nu,rs,sr,tb,vr,ws
set nohlsearch
set noicon
set ignorecase
set noinsertmode
" iskeyword:
" iskeyword=@,48-57,_,192-255 (default)
" Add the dash ('-'), the dot ('.'), and the '@' as "letters" to "words".
" This makes it possible to expand email addresses, eg
" guckes-www at vim.org
set iskeyword=@,48-57,_,192-255,-,., at -@
set joinspaces
set laststatus=2
set lazyredraw
set magic
" modeline: ...
" Allow the last line to be a modeline - useful when
" the last line in sig gives the preferred textwidth for replies.
" set modeline
" set modelines=1
"
set nonumber
set path=.,,/usr/share/vim/vim55/syntax/
set pastetoggle=<f11>
set report=0
set ruler
set shiftwidth=8
set shortmess=at
set showcmd
set showmatch
set showmode
set nostartofline
set splitbelow
set tabstop=8
" Set the colors for vim on "xterm"
if &term=="xterm"
set t_Co=8
set t_AB=[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
set t_AF=[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
endif
set notextmode
set notitle
set nottyfast
set nottybuiltin
set ttyscroll=0
set visualbell
set t_vb=
set whichwrap=<,>,h,l
set wildchar=<TAB>
set wrapmargin=1
" Abbreviations for some important numbers:
iab Npi 3.1415926535897932384626433832795028841972
iab Ne 2.7182818284590452353602874713526624977573
iab Yalpha abcdefghijklmnopqrstuvwxyz
iab YALPHA ABCDEFGHIJKLMNOPQRSTUVWXYZ
iab Ydigit 1234567890
iab Yruler 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
iab Ysuper supercalifragilisticexpialidocious
iab Yanti antidisestablishmentarianism
iab Ypass "You are in a maze of twisty little passages, all alike."
iab Yicty I could tell you - but then I'd have to kill you.
iab Ybtdt Been there, done that, got the tshirt.
" Ysesqui : "Sesquipedalophobia" means "fear of big words." ;-)
iab Ysesqui sesquipedalophobia
iab Yi18n internationalization
iab alos also
iab aslo also
iab bianry binary
iab bianries binaries
iab charcter character
iab charcters characters
iab exmaple example
iab exmaples examples
iab shoudl should
iab seperate separate
iab teh the
iab tpyo typo
iab Ydate <C-R>=strftime("%y%m%d")<CR>
iab Ytime <C-R>=strftime("%H:%M")<CR>
iab YDT <C-R>=strftime("%y%m%d %T")<CR>
iab YDATE <C-R>=strftime("%a %b %d %T %Z %Y")<CR>
" Many shells allow editing in "Emacs Style".
" Although I love Vi, I am quite used to this kind of editing now.
" So here it is - command line editing commands in emacs style:
cnoremap <C-A> <Home>
cnoremap <C-B> <Left>
" cnoremap <C-B> <Del>
cnoremap <C-E> <End>
cnoremap <C-F> <Right>
cnoremap <C-N> <End>
cnoremap <C-P> <Up>
cnoremap <ESC>b <S-Left>
cnoremap <ESC><C-B> <S-Left>
cnoremap <ESC>f <S-Right>
cnoremap <ESC><C-F> <S-Right>
cnoremap <ESC><C-H> <C-W>
cnoremap <ESC>[D <Left>
cnoremap <ESC>[C <Right>
" ===================================================================
" VIM - Editing and updating the vimrc:
" As I often make changes to this file I use these commands
" to start editing it and also update it:
" if has("unix")
" let vimrc='~/.vimrc'
" else
" ie: if has("dos16") || has("dos32") || has("win32")
" let vimrc='$VIM\_vimrc'
" endif
" nn ,u :source <C-R>=vimrc<CR><CR>
" nn ,v :edit <C-R>=vimrc<CR><CR>
" ,v = vimrc editing (edit this file)
" map ,v :e ~/.vimrc<CR>
" ,u = "update" by reading this file
" map ,u :source ~/.vimrc<CR>
" ===================================================================
"
" General Editing
"
" Define "del" char to be the same backspace (saves a LOT of trouble!)
"map <C-V>127 <C-H>
"cmap <C-V>127 <C-H>
" the same for Linux Debian which uses
"imap <Esc>[3~ <C-H>
"imap <C-H>
"cmap <C-H>
" remove whitespace from DOS emails
cmap ;rcm %s/<C-M>//g
" Sws = show whitespace
nmap ,Sws :%s/ /_/g<C-M>
vmap ,Sws :%s/ /_/g<C-M>
" Sometimes you just want to *see* that trailing whitespace:
" Stws = show trailing whitespace
nmap ,Stws :%s/ *$/_/g<C-M>
vmap ,Stws :%s/ *$/_/g<C-M>
" ===================================================================
" ,L = "Last updated" - replace old time stamp with a new one
" preserving whitespace and using internal "strftime" command:
" requires the abbreviation "YDATE"
map ,L 1G/Last update:\s*/e+1<CR>CYDATE<ESC>
map ,,L 1G/Last change:\s*/e+1<CR>CYDATE<ESC>
" Example:
" before: "Last update: Thu Apr 6 12:07:00 CET 1967"
" after: "Last update: Tue Dec 16 12:07:00 CET 1997"
"
" ,L = "Last updated" - replace old time stamp with a new one
" using external "date" command (not good for all systems):
" map ,L 1G/Last update: */e+1<CR>D:r!date<CR>kJ
"
" ===================================================================
" General Editing - link to program "screen"
" ===================================================================
"
" ,Et = edit temporary file of "screen" program
" map ,Et :e /tmp/screen-exchange
" as a user of Unix systems you *must* have this program!
" see also: http://www.math.fu-berlin.de/~guckes/screen/
"
" Email/News - Editing replies/followups
"
" Part 1 - prepare for editing
"
" Part 2 - getting rid of empty (quoted) lines and space runs.
"
" ,cel = "clear empty lines"
map ,cel :%s/^\s\+$//
" ,del = "delete 'empty' lines"
" - delete all lines which contain only whitespace
" note: this does *not* delete empty lines!
map ,del :g/^\s\+$/d
"
" ,cqel = "clear quoted empty lines"
nmap ,cqel :%s/^[>]\+$//
vmap ,cqel :s/^[><C-I> ]\+$//
" NOTE: If the meta sequence "\s" is defined
" The following do not work as "\s" is not a character
" and thus cannot be part of a "character set".
" map ,cqel :g/^[>\s]\+$/d
"
" Turning dot runs with following spaces into an end-of-sentence,
" ie dot-space-space:
vmap ,dot :s/\.\+ \+/. /g
" Gary Kline (kline at tera.tera.com) indents his
" own text in replies with TAB or spaces.
" Here's how to get rid of these indentation:
vmap ,gary :s/^>[ <C-I>]\+\([^>]\)/> \1/
" ,ksr = "kill space runs"
" substitutes runs of two or more space to a single space:
nmap ,ksr :%s/ \+/ /g
vmap ,ksr :s/ \+/ /g
" ,Sel = "squeeze empty lines"
" Convert blocks of empty lines (not even whitespace included)
" into *one* empty line (within current visual):
map ,Sel :g/^$/,/./-j
" ,Sbl = "squeeze blank lines"
" Convert all blocks of blank lines (containing whitespace only)
" into *one* empty line (within current visual):
" map ,Sbl :g/^\s*$/,/[^ <C-I>]/-j
" map ,Sbl :g/^\s*$/,/[^ \t]/-j
map ,Sbl :g/^\s*$/,/\S/-j
" Keyboard mapping for cursor keys
" [works for SUNs in Solarium (room 030) - 970815]
"
map <ESC>OA <Up>
map <ESC>OB <Down>
map <ESC>OC <Right>
map <ESC>OD <Left>
imap <ESC>OA <Up>
imap <ESC>OB <Down>
imap <ESC>OC <Right>
imap <ESC>OD <Left>
"
" Keyboard mapping for cursor keys
" [works for XTerminals - 970818]
map <ESC>[A <Up>
map <ESC>[B <Down>
map <ESC>[C <Right>
map <ESC>[D <Left>
imap <ESC>[A <Up>
imap <ESC>[B <Down>
imap <ESC>[C <Right>
imap <ESC>[D <Left>
if has("syntax")
" The following sources the main syntax file,
" ie. "$VIM/syntax/syntax.vim", see ":help :syn-on":
if &t_Co > 1
syntax on
endif
" Redefine the color for "Comment":
hi! Comment term=bold ctermfg=cyan guifg=Blue
endif
syntax on
More information about the LUG
mailing list