Home Download Buy Blog Forum Support

help with plugin to clean up source

help with plugin to clean up source

Postby maiasaura on Sun Feb 26, 2012 8:36 pm

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:
Code: Select all
x= 1
y= 2
foo= function(x = 1) {
    this =x + 2
    return(this)
}




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

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


Ideas?
maiasaura
 
Posts: 15
Joined: Mon Dec 19, 2011 2:31 am

Re: help with plugin to clean up source

Postby Cjkjvfnby on Sun Feb 26, 2012 10:05 pm

maiasaura wrote: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?


use regular expresion:
view.find_all
Cjkjvfnby
 
Posts: 20
Joined: Wed Feb 01, 2012 11:35 am


Return to Plugin Development

Who is online

Users browsing this forum: Google [Bot] and 10 guests