Vim 7 insert-mode mappings


#1

I’ve just started using Vim (yes, it’s heresy…), and I’m absolutely
loving it – but there are of course still things I haven’t picked up
yet.

One of those things is insert-mode mappings, as described at RubyGarden
[1]. In the section “Customising” there’s a guide on how to add such,
namely this:

imap end-cc

which should be inserted into ftplugin/ruby_structure.vim.

  1. ruby_structure.vim didn’t already exist, so I created it.
    Should it already have existed?

  2. Nothing happens after I’ve added the snippet above to
    ruby_structure.vim. Do I need to do more?

Daniel

[1] http://www.rubygarden.com/ruby/ruby?VimRubySupport


#2

Daniel S. wrote:

which should be inserted into ftplugin/ruby_structure.vim.

[1] http://www.rubygarden.com/ruby/ruby?VimRubySupport

while in insert mode, type

begin

i.e. after keypressing the ‘n’ in begin, press && hold the shift key and
press enter


#3

Reid T. wrote:

while in insert mode, type

begin

i.e. after keypressing the ‘n’ in begin, press && hold the shift key and
press enter

It doesn’t work – it only indents the next line (which it has done all
along). I want it to add the `end’ keyword after that line.

Daniel


#4

Daniel S. wrote:

Daniel

works for me

when you open a .rb file and enter
:imap

what does vim report?


#5

Reid T. wrote:

when you open a .rb file and enter
:imap

what does vim report?

Here’s what I get:

i end-cc

Daniel


#6

Daniel S. wrote:

Daniel

Note: I’m having the same problem with vim70, I added ruby_structure.vim
but it won’t add the “end” also the in my system its adds tabstops I was
expecting two spaces for indenting?

Cheers,

Wink


#7

On 5/15/06, Daniel S. removed_email_address@domain.invalid wrote:

It doesn’t work – it only indents the next line (which it has done all
along). I want it to add the `end’ keyword after that line.

If you are running console-mode Vim (within an Xterm, say, or at the
text-mode Linux VT), then Vim is probably not seeing the shift modifier
applied to the CR. Try gvim (graphical Vim) and see if it works there if
this is the case; it really should. Unfortunately, I don’t know if it’s
possible to get console-mode Vim to see the shift if that’s the problem.


#8

This is the case for me. It works in gvim, but not in regular vim…


#9

Wink Saville wrote:

Note: I’m having the same problem with vim70, I added ruby_structure.vim
but it won’t add the “end”

Ahh, so I’m not the only one. Well, that’s good to know.

also the in my system its adds tabstops I was
expecting two spaces for indenting?

I’m not experiencing that problem. Have you checked your ~/.vimrc file?

Daniel


#10

Jim Marshall wrote:

On 5/15/06, Daniel S. removed_email_address@domain.invalid wrote:

It doesn’t work – it only indents the next line (which it has done all
along). I want it to add the `end’ keyword after that line.
If you are running console-mode Vim (within an Xterm, say, or at the
text-mode Linux VT), then Vim is probably not seeing the shift modifier
applied to the CR. Try gvim (graphical Vim) and see if it works there if
this is the case; it really should. Unfortunately, I don’t know if it’s
possible to get console-mode Vim to see the shift if that’s the problem.

Yes, that seems to be the problem.

Does anyone have a solution to this?

Daniel