English 中文(简体)
六、删除所有空白处,直至下一个非空白之处。
原标题:vim: delete all blank space until next non-blank character
  • 时间:2012-01-13 12:23:00
  •  标签:
  • vim
  • vi

Say I have the following code:

<p>
    Hello
</p>

我也想这样做。

<p>Hello</p>

我要将 cur子置于第1行末的正常状态下,因此,它有权删除所有空间直至其次年。 我认为最接近的是这一动议。

d/Hello

删除一切,直至 然而,问题在于它也删除了 cur(the > )的特性,因此,我最后要删除。

<pHello
</p>

你们怎样做?

最佳回答

当你赢得胜利时,需要多次重复这一行动。

JxJx

解释:

J           # Join current line with next one but substitute end of line with a space.
x           # Remove the space.
Jx          # Repeat same process for last line.
问题回答

There s a tag text-object in vim:

  • put cursor within tag, press vat to select entire tag
  • press :, it becomes : <, >
  • type j, it becomes : <, >j
  • press Enter to join lines

:help v_at

at          "a tag block", select [count] tag blocks, from the
            [count] th unmatched "<aaa>" backwards to the matching
            "</aaa>", including the "<aaa>" and "</aaa>".
            See |tag-blocks| about the details.
            When used in Visual mode it is made characterwise.

当站在第二行的任何地方时(如Hello),则需使用下列钥匙:^d0vatgJ。 简单解释:

  1. ^ will go to the first non-whitespace character, H
  2. d0 will delete to the beginning of the line
  3. vat will select the entire tag
  4. gJ will join all the lines without inserting spaces

If you start on the H, you can skip the ^ part.





相关问题
Autoupdate VIM Plugins?

Is it possible to update vim plugins automatically?

how to unindent in vim without leaving edit mode?

I m writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block....

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

Vim - Deleting XML Comments

How do I delete comments in XML? If the opening and the closing comment tags are on the same line, I use :g/^<!--.*-->$/d to delete the comment. How to delete the comments that are spread ...

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the ...

Profiling Vim startup time

I’ve got a lot of plugins enabled when using Vim – I have collected plugins over the years. I’m a bit fed up with how long Vim takes to start now, so I’d like to profile its startup and see which of ...

热门标签