Re: vmap inline conditional ques

2020-04-08 Thread 'Andy Wokula' via vim_use

Am 08.04.2020 um 01:19 schrieb M Kelly:

Hi,

Is there a way to do an inline conditional such as for demonstration:

vnoremap':let [line_start, col_start] = getpos("v")[1:2]  :let [line_end, col_end] 
= getpos(".")[1:2]  (line_end > line_start) ? "ge" : "b"'

I can do something in a function but that has several exe 'normal ...' 
statements and thus does not draw smoothly.
It seems I cannot get past the :let part.

thx for any help and everything vim,
stay safe everyone during this mess,
-m


The RHS is not a valid expression.

" what I would use using below functions
vnoremap   VisAtEnd(0) ? 'e' : 'w'
vnoremapVisAtStart(0) ? 'b' : 'ge'


" VisAtStart({strict})
"
"   return true if the cursor is in the upper left corner of the Visual
"   area, otherwise false.  If Visual mode is off: returns true always.
"   For {strict}, see VisAtEnd().
"

" VisAtEnd({strict})
"
"   return true if the cursor is in the lower right corner of the Visual
"   area, otherwise false.  If Visual mode is off: returns true always.
"
"   {strict}   (boolean)
"  truemore exact check when in Visual block mode (4 corners)
"  false   always do the charwise/linewise check (2 corners)
"
"   When {strict} is true, then in Visual block mode both VisAtStart() and
"   VisAtEnd() can be false.  See :h v_O .
"


func! VisAtStart(strict) "{{{
if mode() ==? 'v' || !a:strict
return line("v") > line(".") || line("v") == line(".") && col("v") >= 
col(".")
else
" assume Visual block mode
return line("v") >= line(".") && col("v") >= col(".")
endif
endfunc "}}}

func! VisAtEnd(strict) "{{{
if mode() ==? 'v' || !a:strict
return line("v") < line(".") || line("v") == line(".") && col("v") <= 
col(".")
else
" assume Visual block mode
return line("v") <= line(".") && col("v") <= col(".")
endif
endfunc "}}}


--
Andy

--
--
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 vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/5E8E199F.1080804%40yahoo.de.


Re: vmap inline conditional ques

2020-04-08 Thread M Kelly
Andy, hi

Wow, so cool.
All I can say is incredible.
I learn so much from the great people and replies here.

take care,
-m

-- 
-- 
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 vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/23402299-2f9c-4214-ae24-b0cda1f4b1df%40googlegroups.com.


Re: vmap inline conditional ques

2020-04-08 Thread M Kelly
Thank you again Andy.  I'm going to refactor some of my other routines now that 
I learned your better way to do these sort of things.
-m

-- 
-- 
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 vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/d32de68c-edcb-4677-bb11-97d2dc2c3bcc%40googlegroups.com.