what im trying to achieve:
<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 sfrom nerdtree buffer, and
it workedlike 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
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
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 with
pleads to all kind of troubles (using different registers,
<C-v>mapping and also to replace NERDTree with the built-in netrw,
: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 i
really wantedto use
C-Vand to find out what wrong with C-V, because there is something wrong, otherwise
C-Nwouldnt work also.