0

i plugged float-term plugin , that open terminal window in neovim.

when i compile javascript with node in float term i did like :FloatermNew node % then it compiles fine and show me the output in terminal window.

but when i want to make shortcut like this let g:floaterm_keymap_new node % = '<F5>' in my init.vim

it's give me error like this

Error detected while processing /home/visrut/.config/nvim/init.vim:
E121: Undefined variable: g:floaterm_keymap_new
E488: Trailing characters

what should i write?

should we have to write function for that also note that let g:floaterm_keymap_new = '<F5>' works fine but just open terminal.

i also want to do something like on based on filetype you working , i want to like vim script that if filetype is .cpp then it compile with g++ and give ./a.out output to terminal with same shortcut F5.

if you don't know second answer then please just give in first answer of that wrong syntax.

you can checkout plugin keymaps from here https://vimawesome.com/plugin/vim-floaterm#keymaps

1
  • 1
    Please avoid asking more than one question in a single post (How to Ask). Since you’ve already posted an answer, it’s unclear what the best way forward is. I think we should keep this one to be the second question, and you can repost the first one separately.
    – D. Ben Knoble
    Oct 11 '20 at 13:11
0
autocmd FileType javascript nnoremap <buffer> <F5> :w<esc>:FloatermNew node %<CR>
autocmd FileType c nnoremap <buffer> <F5> :w<esc>:FloatermNew gcc % && ./a.out && rm a.out<CR>
autocmd FileType cpp nnoremap <buffer> <F5> :w<esc>:FloatermNew g++ % && ./a.out && rm a.out<CR>
autocmd FileType python nnoremap <buffer> <F5> :w<esc>:FloatermNew python3 %<CR>
2
  • 1
    I think it would be helpful to other users who come across this question if you were to flesh out this answer to more than 4 autocmds (a brief description maybe?). Oct 11 '20 at 15:21
  • You can edit it if you want I will approve it.
    – Visrut
    Oct 11 '20 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.