[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Mutt + Vim tricks (replace Nano)

On Tue, Sep 30, 2003 at 02:13:58PM -0700, Bill Moseley wrote:
| On Tue, Sep 30, 2003 at 02:58:53PM +0000, Monique Y. Herman wrote:
| > On Mon, 29 Sep 2003 22:51:35 -0700, Bill Moseley <moseley@hank.org> penned:
| > 
| > I just created the following last night.  ctrl-j aligns the paragraph to
| > 78 chars; ctrl-k makes it flow; use ':let my_tw=x' before ctrl-L
| > to align it to some arbitrary number.
| > 
| > " Ctrl-J/K formats the current paragraph
| > " gggqG would do the whole file
| > map <C-J> :let old_tw = &tw<CR>:set tw=78<CR>gqap:let &tw=old_tw<CR>
| that seems to work, but only if in normal mode.

That's the intended semantics of 'map'.

| Is it possible to detect the current mode and if in INSERT then
| still work and return in INSERT mode?

:help imap

An excerpt from the summary section of the vim manual :

   :map         {lhs} {rhs}                                     *:map*
   :nm[ap]      {lhs} {rhs}                                     *:nm* *:nmap*
   :vm[ap]      {lhs} {rhs}                                     *:vm* *:vmap*
   :om[ap]      {lhs} {rhs}                                     *:om* *:omap*
   :map!        {lhs} {rhs}                                     *:map!*
   :im[ap]      {lhs} {rhs}                                     *:im* *:imap*
   :lm[ap]      {lhs} {rhs}                                     *:lm* *:lmap*
   :cm[ap]      {lhs} {rhs}                                     *:cm* *:cmap*
                        Map the key sequence {lhs} to {rhs} for the modes
                        where the map command applies.  The result, including
                        {rhs}, is then further scanned for mappings.  This
                        allows for nested and recursive use of mappings.

Basically the map commands are specific to a given mode so that you
can set up different mappings for different modes.

| I'm finding with vim as my mail editor I jump in and out of insert mode
| for things that are kind of basic.  I miss from Nano:
| Control-A/Contrl-E for ^ and $
| Control-J to justify
| Control-W to toggle wrap mode (which would be toggle paste mode in
|   Vim)
| Control-K to kill a link.

I switch back and for between "insert" and "normal" modes easily
enough that it doesn't bother me.  I also tend to leave certain
things, such as rewrapping, until I am done writing in the paragraph.

(BTW & FWIW, I think "edit" is a good description of normal mode)

| And maybe Control-U to undo

^U is still there.


If your life is a hard drive,
Christ can be your backup.

Attachment: pgpIBiGh6uRa4.pgp
Description: PGP signature

Reply to: