Neptune
Neptune

Reputation: 1

Can't give input to programs ran in neovim

When I run code written in C++ or python I can't give Input to the program. For c++

#include <stdio.h>

int main(){
    int test;
    scanf("%d", &test);
    printf("%d\n", test);
    return 0;
}

Outputs

:!g++ -o run test.cpp && ./run  2>&1| tee /tmp/nvimPNNwAf/3                                                                                            
32767

(1 of 1): 32767

For python3

test = input()

Outputs

:!python3 test.py                                                                                                                                      
Traceback (most recent call last):
  File "test.py", line 1, in <module>
  test = input()
EOFError: EOF when reading a line

shell returned 1

I know I can use :term and it would fix it. But I'm having problems with :term.

When I input:

3
10 12 3 9
10 12 7 2
13 11 5 6

It should look like:

3
10 12 3 9
10 12 7 2
13 11 5 6
33
-1
83

However, it outputs:

3                       
10 12 3 9    
10 13                   
2 7 2    
13 11 5 6      
1             
1

How can I fix this issue? (This didn't happen in Vim)

Upvotes: 0

Views: 847

Answers (1)

bensh
bensh

Reputation: 11

For the first part of your question, this is not a big but rather a feature as interactive shell was disabled in neovim, you can see justimk answer on this GitHub issue https://github.com/neovim/neovim/issues/1496 The solution is to invoke your program outside neovim or use a plug-in to do so.

Upvotes: 1

Related Questions