我正在使用 NeoVim,但对于这种情况,我认为如果我们谈论 vim 也是一样的。我已经设置了相对行号 (
set nu rnu
),并且我知道如何从当前光标所在的行复制到带有 yxj
的 x 行,但我需要复制比我能看到的更多的行,所以我首先转到第 247 行,然后我回到第 127 行,我不知道是否有办法指定我要复制到第 247 行(当然,不减去)。
问候
相关文档是
:help change.txt
。我将突出显示一些命令
出现在 :help copy-move
帮助的 change.txt
部分
文档(里面还有更多内容!)。
您可以使用命令行指定要复制的行(即复制,请参阅
:help :y
):
:127,247y
它也适用于相对数字(和模式 - 请参阅
:help range
):
" yank lines 25 before cursor through 3 lines after
" cursor
:-25,+3y
此外,如果您知道要将它们放在哪里,可以使用
t
命令(参见:help :t
):
" copy lines 10 before cursor through 2 lines after
" cursor to 5 lines after the cursor
:-10,-2t+5
您甚至可以混合和匹配相对线和绝对线(以及模式 - 请参阅
:help range
):
" copy from line 23 through to 10 lines before cursor to
" line 51
:23,-10t51
为了完整起见,有
m
命令用于移动(即剪切和粘贴线条,
参见:help :t
):
" move lines 12 before the cursor through to the current
" line to line 27
:-12,.m27
我发现这个插件非常好 - 它会突出显示 Ex 命令的范围 在命令行中输入它们(并向您展示
:substitute
命令如何
在您撰写文件时影响您的文件)。它确实帮助我开始使用
命令行更多。我的 vimrc 中有这个:
" fyi: there is extensive help documentation that's not on the github page
"immediately highlight numerical ranges once you put the comma :N,N
let g:traces_num_range_preview = 1
" window used to show off-screen matches (just 5 since I only want the gist).
let g:traces_preview_window = "below 5new"
" if value is 1, view position will not be changed when highlighting ranges or
" patterns outside initial view position. I like this since I see it all in the
" preview window setting above
let g:traces_preserve_view_state = 1
a
,通过 ma总而言之:247ggma127ggy'a