Forum: Ruby Vim 7 insert-mode mappings

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5da4c52f43677f395aff5bde775593c2?d=identicon&s=25 Daniel Schierbeck (dasch)
on 2006-05-15 17:42
(Received via mailing list)
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 <S-CR>    <CR><CR>end<Esc>-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>
91e1fb8bd265b7629491ab64c42f0906?d=identicon&s=25 Reid Thompson (Guest)
on 2006-05-15 18:07
(Received via mailing list)
Daniel Schierbeck wrote:
> which should be inserted into ftplugin/ruby_structure.vim.
>
>
>
>  [1]  <http://www.rubygarden.com/ruby/ruby?VimRubySupport>
>
while in insert mode, type

begin<shift-enter>



i.e. after keypressing the 'n' in begin, press && hold the shift key and
press enter
5da4c52f43677f395aff5bde775593c2?d=identicon&s=25 Daniel Schierbeck (dasch)
on 2006-05-15 18:23
(Received via mailing list)
Reid Thompson wrote:
> while in insert mode, type
>
> begin<shift-enter>
>
> 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
91e1fb8bd265b7629491ab64c42f0906?d=identicon&s=25 Reid Thompson (Guest)
on 2006-05-15 19:55
(Received via mailing list)
Daniel Schierbeck wrote:
>
>
> Daniel
>
works for me

when you open a .rb file and enter
:imap

what does vim report?
5da4c52f43677f395aff5bde775593c2?d=identicon&s=25 Daniel Schierbeck (dasch)
on 2006-05-15 22:33
(Received via mailing list)
Reid Thompson wrote:
> when you open a .rb file and enter
> :imap
>
> what does vim report?

Here's what I get:

   i  <S-CR>        <CR><CR>end<Esc>-cc


Daniel
D948f30e520e8e8545e1877d77e56b74?d=identicon&s=25 Wink Saville (Guest)
on 2006-05-16 07:06
(Received via mailing list)
Daniel Schierbeck 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
5da4c52f43677f395aff5bde775593c2?d=identicon&s=25 Daniel Schierbeck (dasch)
on 2006-05-16 10:51
(Received via mailing list)
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
0b7911310e2067e9054394a045bd0938?d=identicon&s=25 Jim Marshall (Guest)
on 2006-05-17 22:56
(Received via mailing list)
On 5/15/06, Daniel Schierbeck <daniel.schierbeck@gmail.com> 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.
567898c496278341be69087507d5ed24?d=identicon&s=25 Jeff Rose (Guest)
on 2006-05-18 11:27
(Received via mailing list)
This is the case for me.  It works in gvim, but not in regular vim...
5da4c52f43677f395aff5bde775593c2?d=identicon&s=25 Daniel Schierbeck (dasch)
on 2006-05-18 14:09
(Received via mailing list)
Jim Marshall wrote:
> On 5/15/06, Daniel Schierbeck <daniel.schierbeck@gmail.com> 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
This topic is locked and can not be replied to.