[CLUE-Tech] VIM Questions

Todd A. Gibson tgibson at augustcouncil.com
Thu Jan 24 11:10:35 MST 2002


> I found examples of strftime on the VIM website, but they do not seem to
> work.  All I really want is to easily add the curent date to a file
> while editing.

Well, using the old-fashioned vi way (i.e. I don't know all of vim's
bells and whistles), throw this into .vimrc:

:map #1 i^V^M^[k:r!date^V^MkJJ
:map! #1 ^V^M^V^[k:r!date^V^MkJJa

^V = ctrl-v
^M = the return or enter key
^[ = the excape key

A more easy to read version of them:
:map #1
i
ctrl-v
return
escape
k:r!date
ctrl-v
return
kJJ

:map! #1
ctrl-v
return
ctrl-v
escape
k:r!date
ctrl-v
return
kJJa

This maps function key number 1.  The first is for if you are in command
mode, the second is for if you are in insert mode.

If you look at the manpage for date, you could add options to the date
command to get it in the format you want.

If you are wondering what exactly is happening, just open up a document
in vim, and then type in the keystrokes shown above 
(without the ":map #1" part).
-TAG
 
> Also,  any advise on what keys are 'safe' to remap in an otherwise
> vanilla VIM config?
> 

I don't know with vim.  But in vi the ones that immediately come to mind
are: function keys, g, =
I know there are more, but those are the only ones I remember.
-TAG



More information about the clue-tech mailing list