Ask Your Question
0

Running VIM inside Sage Shell

asked 2018-07-12 16:28:54 +0200

o6p gravatar image

Is this possible? I want to work in Sage shell but I want to use VIM while typing up stuff in sage shell.

edit retag flag offensive close merge delete

Comments

Do you mean in the Sage shell, started by running sage -sh in the terminal, or in the Sage REPL (read-eval-print loop), started by running sage in the terminal?

slelievre gravatar imageslelievre ( 2018-07-12 20:05:04 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2018-07-12 16:41:42 +0200

tmonteil gravatar image

You can use any bash command by starting with !, in you case:

sage: !vim my_file.txt
edit flag offensive delete link more
2

answered 2018-07-13 19:26:25 +0200

Iguananaut gravatar image

updated 2018-07-13 19:29:41 +0200

You can also run

sage: %edit

which will open whatever you have $EDITOR set to first, and then fall back on vi otherwise.

The file is then saved to a temporary file and run when you exit, unless you do %edit -x (then it doesn't execute). While you're in your editor you can also write out to another file if you prefer.

edit flag offensive delete link more

Comments

When I type %edit then 1+1 in vim (which is the editor of my system) and exit, it emits '1+1/n' which is not executed by SAGE. Any help?

pong gravatar imagepong ( 2020-02-23 03:44:59 +0200 )edit

same issue here

jin gravatar imagejin ( 2020-04-30 14:00:39 +0200 )edit

See the documentation for the %edit magic. It's a little confusing, but it does not work exactly the same as entering the code directly in the interactive prompt. If you just write a bare expression like 1 + 1, although it will be evaluated, its results are not displayed. Instead you have to write something like print(1 + 1) if you want the results displayed when executing the code. The %edit command outputs the code entered as a string allowing you to do things like %edit _ to re-edit the previous code.

Iguananaut gravatar imageIguananaut ( 2020-08-03 16:18:08 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-07-12 16:28:54 +0200

Seen: 633 times

Last updated: Jul 13 '18