I am trying to write a function that will only let me call nmap b when the cursor is not on the first column in the current window. This is to make b only work on the current line and encourage more efficient navigation bindings.
I wrote a function which does what I want:
function CurrentLineB() let column = getcurpos() echo column if column != 1 normal b% endif endfunction
When I call it with
:call CurrentLineB() without binding it to
b, it works as expected. When I map the function with
nnoremap b :call CurrentLineB() the function keeps recurring without exiting.
How can I avoid this recursion, and make the function work as it did when it was not bound to b?