早教吧 育儿知识 作业答案 考试题库 百科 知识分享

vim使用问题●Invim/gvim,whatcommandswillindentNconsecutivelines(startingfromthecursorline)byonelevel\x09\x09\x09\x09\x09\x09\x09wheretheindentlevelisdefinedtobetwospaces?Thiswilltaketwovimcommands:onetosetth

题目详情
vim 使用问题
● In vim/gvim, what commands will indent N consecutive lines (starting from the cursor line) by one level
\x09\x09\x09\x09\x09\x09\x09
where the indent level is defined to be two spaces? This will take two vim commands: one to set the
number of spaces to indent with each indent level (default is 8), and one to actually indent N
consecutive lines. Likewise what command will shift N lines left (de-indent N lines)?
\x09\x09\x09\x09\x09\x09
\x09\x09\x09\x09\x09\x09
\x09\x09\x09\x09\x09\x09\x09
● In vim/gvim, what command will indent an entire curly-bracket block one level, while the cursor is
currently on either the open or close curly bracket of the block? Likewise what command will shift an
entire curly-bracket block one level left (de-indent block)?
\x09\x09\x09\x09\x09\x09
\x09\x09\x09\x09\x09\x09
\x09\x09\x09\x09\x09\x09\x09
● How do you open a new line below and insert (one keyboard key for both steps)?
▼优质解答
答案和解析

N>> (N<<)

>% (<%)

o


控制缩进在命令是 > 和 <,在 vim 里还是比较常用的。

不过这些问题还考察了在上下文环境里应用。


vim 里有个重要的概念叫:文本对象(text-object)。要理解深入才能发挥 vim 的灵活。

因此第二个问题,还有一个答案是 >a{。在需要的时候,可能更方便。