Command mode move to matching paren/brace/bracket/angles... like '%'

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Command mode move to matching paren/brace/bracket/angles... like '%'

jjlu...@yahoo.com
Please help me find a way to move to the matching char pair from within a :source'd script...
Something like the Command mode move to matching paren/brace/bracket/angles... using the '%' key... but from the :source'd script...

Tim Chase mentions in another article (reference below) using % to move to the matching in normal mode.  The CTRL-O in insert mode was interesting as well... 

I'm trying to use a "move to matching" inside a :source'd script.  Is there a way to still move to matching brace after finding the start brace inside the :source'd script?

more info....

I tried a line with a single percent '%' and it moves the cursor to the end of the file. So I always got from the starting point to the end of the file and not the matching brace.

After reading Tim's response, I also tried something like this after finding the starting brace.  Here I am typing out the characters representing the characters i, CTRL-o, %,  escape key, where CTRL-o and escape were entered using the escaping key mech of CTRL-V (linux): 
i^O%^[

thanks for looking and thanks in advance for the help... newbie...  
Jim



=================================
From: https://groups.google.com/g/vim_use/c/PK4JmlsmoI8/m/hlerEqNqF8oJ
Subject: How to move cursor in insert mode?
Credit: Tim Chase

Some gross movements (such as by word or screen) can be done in 
insert-mode as well (control+left/right, home/end, pgup/dn) 
though some may be limited to gvim. For some of the other 
vim-specific movements, you can also use control+o ("oh", not 
"zero") to temporarily enter normal mode to issue one normal-mode 
command such as "%" to move to the matching paren/brace/bracket 
or ")" to move to the next sentence. All your typical motions 
should work here.

:help i_CTRL-O
:help motion.txt

-tim

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ef3b8e01-72fe-494f-b1ef-b1a9494f880bn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Command mode move to matching paren/brace/bracket/angles... like '%'

Gary Johnson-4
On 2020-10-08, '[hidden email]' via vim_use wrote:

> Please help me find a way to move to the matching char pair from within a
> :source'd script...
> Something like the Command mode move to matching paren/brace/bracket/angles...
> using the '%' key... but from the :source'd script...
>
> Tim Chase mentions in another article (reference below) using % to move to the
> matching in normal mode.  The CTRL-O in insert mode was interesting as well...
>
> I'm trying to use a "move to matching" inside a :source'd script.  Is there a
> way to still move to matching brace after finding the start brace inside the
> :source'd script?

I think you're looking for the :normal command.  See

    :help :normal

Then you can put this in your script to move the cursor to the
matching item:

    normal %

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201008174548.GC17599%40phoenix.
Reply | Threaded
Open this post in threaded view
|

Re: Command mode move to matching paren/brace/bracket/angles... like '%'

jjlu...@yahoo.com
very cool... worked like a charm Gary, thank you for sharing!!

On Thursday, October 8, 2020 at 12:46:26 PM UTC-5 Gary Johnson wrote:
On 2020-10-08, '[hidden email]' via vim_use wrote:

> Please help me find a way to move to the matching char pair from within a
> :source'd script...
> Something like the Command mode move to matching paren/brace/bracket/angles...
> using the '%' key... but from the :source'd script...
>
> Tim Chase mentions in another article (reference below) using % to move to the
> matching in normal mode. The CTRL-O in insert mode was interesting as well...
>
> I'm trying to use a "move to matching" inside a :source'd script. Is there a
> way to still move to matching brace after finding the start brace inside the
> :source'd script?

I think you're looking for the :normal command. See

:help :normal

Then you can put this in your script to move the cursor to the
matching item:

normal %

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/0cd36638-a03d-4dc7-9176-2c0e7983fa3bn%40googlegroups.com.