Skip to main content
added 7 characters in body
Source Link
statox
  • 50.6k
  • 19
  • 153
  • 231

I) Don't create an insert mode mapping:

Insert mode is made to insert characters, when you need to move your cursor you should go back to normal mode or use ctrl+o to go to normal mode for only one command. (:h i_CTRL-O)

II) Use the built-in motion command:

In normal mode f+character goes to the next character (:h f). For example:

"foo bar| baz"

In normal mode pressing f" will put the cursor on the second " and a will start insert mode after this character.

Thus in the previous example from insert mode I would use esc+f+"+a. This has the benefit to seperate your edit in different undoable chunck of edits which is how you're supposed to use Vim.


Now if you still want to what you asked I think you'll have to create a function which will try to detect in which text object the cursor is currently and then move to the end of this text object. In my opinion that is more trouble than simply using Vim as it is meant to be used.

Edit

You may also be interested by the % command which cycles through matching groups (:h matchit-%):

For example:

inoremap <leader>, <esc>%%a

Would do the trick for the matching brackets ((, {, () but not for the quotes.

I) Don't create an insert mode mapping:

Insert mode is made to insert characters, when you need to move your cursor you should go back to normal mode or use ctrl+o to go to normal mode for only one command. (:h i_CTRL-O)

II) Use the built-in motion command:

In normal mode f+character goes to the next character (:h f). For example:

"foo bar| baz"

In normal mode pressing f" will put the cursor on the second " and a will start insert mode after this character.

Thus in the previous example from insert mode I would use esc+f+"+a. This has the benefit to seperate your edit in different undoable chunck of edits which is how you're supposed to use Vim.


Now if you still want to what you asked I think you'll have to create a function which will try to detect in which text object the cursor is currently and then move to the end of this text object. In my opinion that is more trouble than simply using Vim as it is meant to be used.

You may also be interested by the % command which cycles through matching groups (:h matchit-%):

For example:

inoremap <leader>, <esc>%%a

Would do the trick for the matching brackets ((, {, () but not for the quotes.

I) Don't create an insert mode mapping:

Insert mode is made to insert characters, when you need to move your cursor you should go back to normal mode or use ctrl+o to go to normal mode for only one command. (:h i_CTRL-O)

II) Use the built-in motion command:

In normal mode f+character goes to the next character (:h f). For example:

"foo bar| baz"

In normal mode pressing f" will put the cursor on the second " and a will start insert mode after this character.

Thus in the previous example from insert mode I would use esc+f+"+a. This has the benefit to seperate your edit in different undoable chunck of edits which is how you're supposed to use Vim.


Now if you still want to what you asked I think you'll have to create a function which will try to detect in which text object the cursor is currently and then move to the end of this text object. In my opinion that is more trouble than simply using Vim as it is meant to be used.

Edit

You may be interested by the % command which cycles through matching groups (:h matchit-%):

For example:

inoremap <leader>, <esc>%%a

Would do the trick for the matching brackets ((, {, () but not for the quotes.

added 163 characters in body
Source Link
statox
  • 50.6k
  • 19
  • 153
  • 231

I) Don't create an insert mode mapping:

Insert mode is made to insert characters, when you need to move your cursor you should go back to normal mode or use ctrl+o to go to normal mode for only one command. (:h i_CTRL-O)

II) Use the built-in motion command:

In normal mode f+character goes to the next character (:h f). For example:

"foo bar| baz"

In normal mode pressing f" will put the cursor on the second " and a will start insert mode after this character.

Thus in the previous example from insert mode I would use esc+f+"+a. This has the benefit to seperate your edit in different undoable chunck of edits which is how you're supposed to use Vim.


Now if you still want to what you asked I think you'll have to create a function which will try to detect in which text object the cursor is currently and then move to the end of this text object. In my opinion that is more trouble than simply using Vim as it is meant to be used.

You may also be interested by the % command which cycles through matching groups (:h matchit-%):

For example:

inoremap <leader>, <esc>%%a

Would do the trick for the matching brackets ((, {, () but not for the quotes.

I) Don't create an insert mode mapping:

Insert mode is made to insert characters, when you need to move your cursor you should go back to normal mode or use ctrl+o to go to normal mode for only one command. (:h i_CTRL-O)

II) Use the built-in motion command:

In normal mode f+character goes to the next character (:h f). For example:

"foo bar| baz"

In normal mode pressing f" will put the cursor on the second " and a will start insert mode after this character.

Thus in the previous example from insert mode I would use esc+f+"+a. This has the benefit to seperate your edit in different undoable chunck of edits which is how you're supposed to use Vim.


Now if you still want to what you asked I think you'll have to create a function which will try to detect in which text object the cursor is currently and then move to the end of this text object. In my opinion that is more trouble than simply using Vim as it is meant to be used.

I) Don't create an insert mode mapping:

Insert mode is made to insert characters, when you need to move your cursor you should go back to normal mode or use ctrl+o to go to normal mode for only one command. (:h i_CTRL-O)

II) Use the built-in motion command:

In normal mode f+character goes to the next character (:h f). For example:

"foo bar| baz"

In normal mode pressing f" will put the cursor on the second " and a will start insert mode after this character.

Thus in the previous example from insert mode I would use esc+f+"+a. This has the benefit to seperate your edit in different undoable chunck of edits which is how you're supposed to use Vim.


Now if you still want to what you asked I think you'll have to create a function which will try to detect in which text object the cursor is currently and then move to the end of this text object. In my opinion that is more trouble than simply using Vim as it is meant to be used.

You may also be interested by the % command which cycles through matching groups (:h matchit-%):

For example:

inoremap <leader>, <esc>%%a

Would do the trick for the matching brackets ((, {, () but not for the quotes.

Source Link
statox
  • 50.6k
  • 19
  • 153
  • 231

I) Don't create an insert mode mapping:

Insert mode is made to insert characters, when you need to move your cursor you should go back to normal mode or use ctrl+o to go to normal mode for only one command. (:h i_CTRL-O)

II) Use the built-in motion command:

In normal mode f+character goes to the next character (:h f). For example:

"foo bar| baz"

In normal mode pressing f" will put the cursor on the second " and a will start insert mode after this character.

Thus in the previous example from insert mode I would use esc+f+"+a. This has the benefit to seperate your edit in different undoable chunck of edits which is how you're supposed to use Vim.


Now if you still want to what you asked I think you'll have to create a function which will try to detect in which text object the cursor is currently and then move to the end of this text object. In my opinion that is more trouble than simply using Vim as it is meant to be used.