Display name
Display name

Reputation: 4481

R Studio won't insert tabs, instead displays `(No matches)` - How to fix?

I'm trying to pad my R Studio code with a bunch of "white space" between said code and comments. See the image below.

R studio no matches

Every time I try to add padding by hitting Tab on my keyboard I instead get a (No matches) warning? How do I disable this behavior? Here's a repro:

library(ggplot2)                        # line 1
p1 <- ggplot(mtcars, aes(disp, mpg)) +  # line 2
  geom_point()                          # line 3

ggplot(mtcars, aes(mpg, disp)) +        # line 5
  geom_point()                          # line 6

10 + 10                                 # line 8    

Upvotes: 3

Views: 2226

Answers (3)

AdamO
AdamO

Reputation: 4920

You need to untick the following option from the Tools > Show Command Pallet enter image description here

Autocompletion was the bee's knees in the primordial days of IDEs. It seems we've come full circle. But I sometimes have need for a tab here or there, and not according to Rstudio's stringent tabbing rules. For instance, I hate editing output from dput, so for inline data creation I create a little tab separated data table with read.delim2(textConnection(<tabbed stuff>)))

Anyway, a cheater's trick is to create a tab separately in a lightweight text editor (hi, Notepad), and paste it into your Rstudio R file tab.

Upvotes: 1

user10191355
user10191355

Reputation:

I don't think it's possible, but you shouldn't disable it anyway. The tab key is used for code completion, which is far more useful for a programmer than a regular tab. If you hit the tab button a second time it should tab normally.

Whenever I want multiple tabs I just copy and paste, which can be much faster anyway because you can copy and paste multiple tabs at once. Also, you should know that tabs in RStudio are just four spaces, so you can also use the spacebar (plus copy and paste) and every chunk of four spaces will be treated as a tab.

One more thing: Your "comments" are superfluous because the line number is already there on the left. Any good IDE will have line numbers, so adding them isn't necessary. Inline comments should also be used sparingly.

Upvotes: 1

Not_Dave
Not_Dave

Reputation: 501

tabs are usually used to complete the object name or function name. For example if I type library(ggp and press tab, it will complete it as library(ggplot). If you want tab space, go to new line and press tab and that will give you tab formatting.

This should hep you support.rstudio.com

Upvotes: 2

Related Questions