开发者

VIM: Deleting from current position until a space

开发者 https://www.devze.com 2022-12-09 08:19 出处:网络
Often when developing I am confronted with a nested object that I\'d like to delete from code in the middle of a line like this:

Often when developing I am confronted with a nested object that I'd like to delete from code in the middle of a line like this:

htmlDoc.WriteLine("<b><h3>" + this.cbAllSyncs.SelectedItem.ToString() + "</h3></b>");

The part that I'd like to delete is:

this.cbAllSyncs.SelectedItem.ToString()

I know I can cou开发者_StackOverflownt the number of words and periods and enter 7dw to delete from my current cursor position of "this". However, what I'd love to do is not have to count at all and delete to the space with one command. Is this possible?


Try dtspace. In general dtx deletes from current position till just before x. Just tx moves the cursor to just before character x in current line.

To delete up to and including the space, use dfspace.


You can use dW or dE as @glenn suggested if you don't want to delete the space itself.

A WORD (uppercase W) consists of a sequence of non-blank characters, separated with white space.

Give a look to the word motions.


one possible solution is to use the delete with a search.

so type in d/<space> and vim will delete until it hits a space.


If you want to delete from anywhere inside the WORD, and in a single command, just use daW

(you can of course use daw if you want to limit to a word)

I use it quite a lot because it spare a move to the begining of the word (in your case)


  • delete for the current position to a specific character example "

    dt"
  • delete the word from the position cursor is on till the end of the word

    dw
  • delete the entire word the cursor is on irrespective of the position the cursor is on the word, this also puts you in insert mode to enable you to insert immediately.

    diw


dtspace is the answer to your question, but df+ looks like it will solve your problem better.

0

精彩评论

暂无评论...
验证码 换一张
取 消