Search code examples
rsublimetext2sublimerepl

Sublime: Running script from cursor until begin script without select lines


I am using Sublime to work with R via Repl, all works fine...

But I wonder if its possible run commands lines from cursor until the begin of script without select lines above the cursor...

Because when I select lines above the cursor to run script, the cursor dont back to my last place that I was working and sometimes its dificult find my last place to continue with my work...

I am not expert programer and probably I miss a lot of tips to do it.

Below the cursor exist other command lines that I dont wanna run:

rm(list=ls()) 
library(dplyr)
library(readxl)
library(rtf)
library(ggplot2)
library(data.table)

df=mtcars

View(df)

| #Cursor here, only run codes above it

str(df)
summary(df)
names(df)

Solution

  • To select the lines, hold down Shift and either use to select all the above lines, or simply click at the beginning with your mouse. The keyboard shortcut Ctrl,, S (hit Ctrl+comma, release, and hit S) will eval the selection in SublimeREPL. Once you switch back to your code with the selection, simply hit (right arrow) and your cursor will be back where it was at the end of the selection.

    To answer your question: No, there is no way to evaluate all the content above your cursor in a REPL via a command or keyboard shortcut. You can evaluate the whole file, the current line, the current selection, or the current block of code.