2

I want to create an abbreviation for multiple lines. For example, when I type Doc, it has to print a four line text like

###############
# function :
# returns :
#
##############

When I tried to do this the first line works, but other lines aren't inserted.

I tired with abbr, iabbr and imap. I'm not able to get the desired behavior. I would prefer not to write a function to do that.

4

yes, you can do with the ^M character in your abbrev, for example:

iabbrev Doc #^M# function :^M#^M# returns :^M#

will be transformed into:

#
# function :
# 
# returns :
#

To get ^M you need to type <C-v> <CR>.

  • Thanks. But still I couldn't get it. I wrote this command line in a plaugin. Is it necessary that I need to write this line directly in .vimrc? It doesn't work – SibiCoder Apr 19 '16 at 11:30
  • 1
    you can use it directly in your command line to try it out first. What output do you get? – nobe4 Apr 19 '16 at 11:30
  • 1
    I tried. Sorry, my multiline text has pipeline after ^M. That is the problem I think. I escaped it. Bow it works :) – SibiCoder Apr 19 '16 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.