Sublime Forum

Help with plugin to clean up source

#1

The assignment operator in R is <-
Although = also works, it is better practice to use <-

Is there a way to write a plugin that would do this replacement on a currently open file without replacing = signs inside parentheses?

so this:

x= 1
y= 2
foo= function(x = 1) {
    this =x + 2
    return(this)
}

should become (note one space on either side of <-

x <- 1 y <- 2 foo <- function(x = 1) { this <- x + 2 return(this) }

Ideas?

0 Likes

#2

[quote=“maiasaura”]The assignment operator in R is <-
Is there a way to write a plugin that would do this replacement on a currently open file without replacing = signs inside parentheses?
[/quote]

use regular expresion:
view.find_all

0 Likes