what im trying to achieve:
- use
<C-V>
to paste text in normal mode in current buffer - use same
<C-V>
to vertically split a file from nerdtree
what i know:
- when you are with your cursor in nerdtree and you press the letter
s
, it will split the file under cursor vertically ( from docs:" s: open vsplit
)
what i tried:
:normal s
from nerdtree buffer, andit worked
like a charm.
in init.vim i have this:
" this function works, i tried it many times
function IsCurrentWindowNERDTree()
return exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) == winnr()
endfunction
function Control_v_key_binding()
if IsCurrentWindowNERDTree()
" problem is here !!!
normal s
else
" this just pastes the text from os clipboard
normal "+p
endif
endfunction
nnoremap <C-V> :call Control_v_key_binding()<CR>
inoremap <C-V> <C-O>:call Control_v_key_binding()<CR>
in function, i tried:
- execute "normal \s"
- normal \s
- normal s
i mapped nnoremap <C-N> :normal s<CR>
for control+N and it worked.
function Control_v_key_binding()
if IsCurrentWindowNERDTree()
normal s
else
normal "+p
endif
endfunction
" this is really stupid, this configuration works flawlessly
nnoremap <C-N> :call Control_v_key_binding()<CR>
" and this doesnt work
nnoremap <C-V> :call Control_v_key_binding()<CR>
some weird part, i debugged this function and it just wont enter in the first if
, goes automatically on else
, but works on every other case for other keybindings, my function IsCurrentWindowNERDTree
works everytime ; i binded nnoremap <C-V> :normal s<CR>
, doesnt work either.
i dont understand what is wrong with <C-V>
any ideas? thanks
<C-v>
to paste text is a great way to cause issues in the future:<C-v>
is super useful for visual block selection and not pasting withp
leads to all kind of troubles (using different registers,p
vsP
,etc)<C-v>
mapping and also to replace NERDTree with the built-in netrw,:ls
,:b
, `:find, etc and maybe a fuzzy finder if you really need one.fzf
, i just like nerd tree standing alone there in the left. i solved the problem my selecting another keybinding, but ireally wanted
to useC-V
and to find out what wrong with C-V, because there is something wrong, otherwiseC-N
wouldnt work also.