How to search for an inappropriate template in VIM

Here is a snippet of my .py file:

 for i in range(1,nxs-2): for j in (1, nts-2): dg_cc(dg,sina,cosa,s,r2tanb,omega,L,n,m,xs[i],ts[k],pd) dot( dg,F,c1,transa=T ) dot( c1, dg, ansK1, N, N, alpha=2., beta=1. ) # linear buckling part g = g_cc(m,n,L,xs[i],ts[j],pd) Bg = fBg(Bg,cosa,s,L,m,n,xs[i],ts[i],pd) dot( g, Bg, ansK1, T, N, alpha=2., beta=1. ) # if pd: fdg0(dg0,sina,cosa,s,r2tanb,omega,L,xs[i],ts[j]) dot( dg0, F, c2, transa=T ) dot( c2, dg, ansK0, N, N, alpha=2., beta=1. ) for i in (1, nxs-2): for j in range(1,nts-2): dg_cc(dg,sina,cosa,s,r2tanb,omega,L,n,m,xs[i],ts[n],pd) dot( dg,F,c1,transa=T ) dot( c1, dg, ansK1, N, N, alpha=2., beta=1. ) # linear buckling part g = g_cc(m,n,L,xs[i],ts[j],pd) Bg = fBg(Bg,cosa,s,L,m,n,xs[i],ts[j],pd) dot( g, Bg, ansK1, T, N, alpha=2., beta=1. ) 

I have to fix all typos, keeping only ts[j] and correcting them, for example, using ts[i] or ts[n] .

How to create a search pattern to get where ts[something] something NOT equal j ?

+4
source share
3 answers

You can try this, see if it works for your requirement?

 /ts\[[^j]\] 
+7
source

If the pattern you wanted to cancel was more than one character, you could use a negative result. Which matches if the template does NOT match the current position.

 /ts\[\(j\)\@!.\{-}] 

or with a very magical

 /\vts\[(j)@!.{-}] 

If the pattern is rejected, if before @! in this case j . .{-} is not a greedy match that is used to match all values ​​up to the next square bracket.

+4
source

The following should work for you:

 /ts[[][^j]] 

or shielding [ :

 /ts\[[^j]] 
+1
source

Source: https://habr.com/ru/post/1496606/


All Articles