This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/navigating-within-ruby-files
This may be an odd question, but how do you actually type [
or ]
on Vim? Iām on a spanish keyboard, and Iāve tried with either shift
, ctrl
, alt
and fn
+ the key where [
is placed. Nothing works for me, and I havenāt even found answers on google. Thanks!
Hope this will help you. windows xp - How to resolve the annoyance with switching keyboard layouts for different languages in Vim? - Stack Overflow
Thank you @NicholasTD07 ! This looks like a really source source of information. Iāll carefully read it and post here what I come up with for reference.
I canāt find the link for the cheatsheet. Is that still available?
How does one debug the fact that hitting %
doesnāt do anything when on the d
of a word do
in a ruby file? Hereās my vim config folder:
Note that the plugin textobj-rubyblock depends on kana/vim-textobj-user, so you should install that plugin first.
Really useful video. Iām having trouble with the module and method text objects.
im
am
iM
aM
When I try to invoke one of them (say vam
) I get the error message:
E117: Unknown function: <SRN>106_wrap_a
or 106_wrap_i
for vim
I have the necessary plug-ins loaded and var
and vir
work.
How do I troubleshoot this?
I noticed something unexpected. Using var
to highlight a block, then using ar
and ir
should expand and contract the selection. However ir
does not contract the selection.
Using your example:
module Foo
class Bar
def baz
[1,2,3].each do |i|
i + 1
end
end
end
end
- Starting on the line with
each
and hittingvir
the inside of thebaz
method is selected as expected. - Now typing
ar
expands the selection to the wholebaz
method (fromdef
toend
). - However, typing
ir
now does nothing. - Typing
ar
at this point will expand the selection to theBar
class. - Again
ir
does nothing at this point. - Once again typing
ar
will expand the selection to the whole module. - Now typing
ir
will shrink the selection to the inside of the module. - At this point
ar
will expand to the whole module. - Here
ir
ar
will contract and expand the selection, but only at the top level. If we try to typeir
twice it only contracts once.
I suspect that because the blocks are nested once you are at 2. you have highlighted the baz
method (around the previously selected inside) when you invoke ir
it does nothing because it says you are already at the inside of the class Bar
and therefore nothing happens.
What is odd is that I used the same text as the video but the behavior is different. I tried this on a number of real world ruby files with the same effect.
How do I troubleshoot this?