Open a file in RStudio, optionally at a specified location.
navigateToFile(
file = character(0),
line = -1L,
column = -1L,
moveCursor = TRUE
)
The file to be opened.
The line number where the cursor should be placed. When -1L
(the default), the cursor will not be moved.
The column number where the cursour should be placed. When
-1L
(the default), the cursor will not be moved.
Boolean; should the cursor be moved to the requested
(line
, column
) position? Set this to FALSE
to preserve the existing
cursor position in the document.
The navigateToFile
opens a file in RStudio. If the file is already
open, its tab or window is activated.
Once the file is open, the cursor is moved to the specified location. If the
file
argument is empty (the default), then the file is the file
currently in view if one exists. If the line
and column
arguments are both equal to -1L
(the default), then the cursor
position in the document that is opened will be preserved. Alternatively,
moveCursor
can be set to FALSE
to preserve the cursor position.
Note that if your intent is to navigate to a particular function within a
file, you can also cause RStudio to navigate there by invoking
View
on the function, which has the advantage of
falling back on deparsing if the file is not available.