在vim中搜索选择(Search for selection in vim)
在编写C ++时,我使用vim和vim插件进行visual studio。 通常,我发现自己想在函数中搜索一个字符串,例如每次调用
object->public_member.memberfunc()
。我知道vim提供了一种方便的方式来搜索一个单词,通过按
*
和#
,它也可以使用无处不在的斜线/
命令搜索类型的字符串。 当尝试搜索如上所述的较长字符串的所有实例时,需要一段时间才能在/
之后重新输入。有没有办法搜索选择? 例如,用
v
突出显示,然后用y
复制,有没有办法粘贴/
? 有更容易的捷径吗?I use vim and vim plugins for visual studio when writing C++. Often, I find myself wanting to search for a string within a function, for example every call to
object->public_member.memberfunc()
.I know vim offers a convenient way to search for a single word, by pressing
*
and#
, and it can also search for typed strings using the ubiquitous slash/
command. When trying to search for all the instances of a longer string like the one above, it takes a while to re-type after/
.Is there a way to search for selection? For example, highlight with
v
, then copy withy
, is there a way to paste after/
? Is there an easier shortcut?
原文:https://stackoverflow.com/questions/363111
最满意答案
更新:将
list.dirs
功能添加到版本54353的基础包中,该包已包含在2011年4月的R-2.13.0版本中。list.dirs(path = ".", full.names = TRUE, recursive = TRUE)
所以我下面的功能只用了几个月。 :)
我找不到一个基本的R函数来做,但是很容易用自己编写的:
dir()[file.info(dir())$isdir]
更新:这是一个功能(现在更正了Timothy Jones的评论):
list.dirs <- function(path=".", pattern=NULL, all.dirs=FALSE, full.names=FALSE, ignore.case=FALSE) { # use full.names=TRUE to pass to file.info all <- list.files(path, pattern, all.dirs, full.names=TRUE, recursive=FALSE, ignore.case) dirs <- all[file.info(all)$isdir] # determine whether to return full names or just dir names if(isTRUE(full.names)) return(dirs) else return(basename(dirs)) }
Update: A
list.dirs
function was added to the base package in revision 54353, which was included in the R-2.13.0 release in April, 2011.list.dirs(path = ".", full.names = TRUE, recursive = TRUE)
So my function below was only useful for a few months. :)
I couldn't find a base R function to do this, but it would be pretty easy to write your own using:
dir()[file.info(dir())$isdir]
Update: here's a function (now corrected for Timothy Jones' comment):
list.dirs <- function(path=".", pattern=NULL, all.dirs=FALSE, full.names=FALSE, ignore.case=FALSE) { # use full.names=TRUE to pass to file.info all <- list.files(path, pattern, all.dirs, full.names=TRUE, recursive=FALSE, ignore.case) dirs <- all[file.info(all)$isdir] # determine whether to return full names or just dir names if(isTRUE(full.names)) return(dirs) else return(basename(dirs)) }
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
您可以使用以下正则表达式解决list.files()缺少perl=T支持的list.files() : ^(.|[^S].*|.[^H].*)\\.csv 这是一个关于这个正则表达式如何工作的演示 此正则表达式允许任何单字符文件名,或开头没有SH双字符文件名和任何其他文件名。 所以,使用 myFiles = list.files(pattern = "^(.|[^S].*|.[^H].*)\\.csv") You can use the following regex to work around th ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
更新:将list.dirs功能添加到版本54353的基础包中,该包已包含在2011年4月的R-2.13.0版本中。 list.dirs(path = ".", full.names = TRUE, recursive = TRUE) 所以我下面的功能只用了几个月。 :) 我找不到一个基本的R函数来做,但是很容易用自己编写的: dir()[file.info(dir())$isdir] 更新:这是一个功能(现在更正了Timothy Jones的评论): list.dirs <- function(path ...
-
看起来默认引擎不喜欢外观,所以你需要使用Perl。 这有效: dat <- c("Camera1.png", "Camera2.png", "hello.png", "boo") grep("^(?!Camera1).*\\.png", dat, value=T, perl=T) # [1] "Camera2.png" "hello.png" 但这不是: grep("^(?!Camera1).*\\.png", dat, value=T) # invalid regular expression '(? ...
-
public static void main (String[] args) throws Exception { File dir = new File("yourDir"); FileFilter fileFilter = new FileFilter() { public boolean accept(File file) { return file.isDirectory(); } }; File[] f ...
-
list_files <- list.files(path="my_file_path", recursive = TRUE, pattern = "un[0-9]", full.names = TRUE) list_files <- list.files(path="my_file_path", recursive = TRUE, pattern = "un[0-9]", full.names = TRUE)
-
尽管在list.files中,为什么file.exists返回FALSE?(Why does file.exists return FALSE despite being in list.files?)[2022-05-08]
Windows有一个文件名长度的上限(260个字符),超出了x 。 缩短文件导致file.exists返回TRUE 。 Windows has an upper limit on the length of a filename (260 characters), which x exceeded. Shortening the file resulted in file.exists returning TRUE. -
list.files与模式与完整文件名不匹配。 与上面的注释类似,另一种方法是将grep应用于结果,或将其应用于您作为参数提供的路径列表,例如: files <- rev( list.files( grep( "Sample_73", list.dirs( "../runs" ), value=TRUE), "*.gene.read.count", full.names=TRUE)) list.files will not match the pattern to the full file name. ...
-
您可以使用Filter筛选目录列表 testSite <- "australia.gov.au" Filter(function(x) grepl(paste0("^", gsub(".", "\\.", testSite, fixed=TRUE)), x), list.dirs()) 我们做了一些额外的工作来将您的URL转换为正则表达式来进行匹配。 You can use Filter to filter your directory list testSite <- "australia.go ...