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
eachand hittingvirthe inside of thebazmethod is selected as expected. - Now typing
arexpands the selection to the wholebazmethod (fromdeftoend). - However, typing
irnow does nothing. - Typing
arat this point will expand the selection to theBarclass. - Again
irdoes nothing at this point. - Once again typing
arwill expand the selection to the whole module. - Now typing
irwill shrink the selection to the inside of the module. - At this point
arwill expand to the whole module. - Here
irarwill contract and expand the selection, but only at the top level. If we try to typeirtwice 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?