Linux.com

One use for mappings

Posted by: Administrator on June 15, 2006 12:00 AM

Mappings are great. To give you another idea for their use, here is one thing that I use vim mappings for, changing the email signature I use:




map ns<nobr> <wbr></nobr>/^-- ^Md}:read ~/.signature^M

map suso<nobr> <wbr></nobr>/^-- ^Md}:read ~/.signature^M

map blug<nobr> <wbr></nobr>/^-- ^Md}:read ~/.signature-blug^M

map bloomingpedia<nobr> <wbr></nobr>/^-- ^Md}:read<nobr> <wbr></nobr>/.signature-bloomingpedia^M

map personal<nobr> <wbr></nobr>/^-- ^Md}:read ~/.signature-personal^M




Those ^M are actually the newline control character so you'll need to type Ctrl-V + Ctrl-M to get them. I have to use them in place of <CR> for it to actually work on older versions of vim like 6.3. So all you have to do to switch signatures is just type in the mapped word. Makes it handy to change your identity for the email that you are writing.



The first one, 'ns' can be useful if you're using a random signature generating program and you want to cycle through the signatures (like my <a href="http://suso.suso.org/programs/randomsig/" title="suso.org">randomsig </a suso.org> program)



Another useful thing is to map noi to turn off all the indenting options when you need to paste something into a file.


map noi<nobr> <wbr></nobr>:set noautoindent<CR>:set nosmartindent<CR>

#

Return to Vim tips: Using Vim mappings and abbreviations