ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 03 Aug 2020 16:18:08 +0200Running VIM inside Sage Shellhttps://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/Is this possible? I want to work in Sage shell but I want to use VIM while typing up stuff in sage shell. Thu, 12 Jul 2018 16:28:54 +0200https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/Comment by slelievre for <p>Is this possible? I want to work in Sage shell but I want to use VIM while typing up stuff in sage shell. </p>
https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?comment=42979#post-id-42979Do 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?Thu, 12 Jul 2018 20:05:04 +0200https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?comment=42979#post-id-42979Answer by Iguananaut for <p>Is this possible? I want to work in Sage shell but I want to use VIM while typing up stuff in sage shell. </p>
https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?answer=43004#post-id-43004You 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.Fri, 13 Jul 2018 19:26:25 +0200https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?answer=43004#post-id-43004Comment by jin for <p>You can also run</p>
<pre><code>sage: %edit
</code></pre>
<p>which will open whatever you have <code>$EDITOR</code> set to first, and then fall back on <code>vi</code> otherwise.</p>
<p>The file is then saved to a temporary file and run when you exit, unless you do <code>%edit -x</code> (then it doesn't execute). While you're in your editor you can also write out to another file if you prefer.</p>
https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?comment=51161#post-id-51161same issue hereThu, 30 Apr 2020 14:00:39 +0200https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?comment=51161#post-id-51161Comment by Iguananaut for <p>You can also run</p>
<pre><code>sage: %edit
</code></pre>
<p>which will open whatever you have <code>$EDITOR</code> set to first, and then fall back on <code>vi</code> otherwise.</p>
<p>The file is then saved to a temporary file and run when you exit, unless you do <code>%edit -x</code> (then it doesn't execute). While you're in your editor you can also write out to another file if you prefer.</p>
https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?comment=52833#post-id-52833See the documentation for the [`%edit` magic](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-edit). 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.Mon, 03 Aug 2020 16:18:08 +0200https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?comment=52833#post-id-52833Comment by pong for <p>You can also run</p>
<pre><code>sage: %edit
</code></pre>
<p>which will open whatever you have <code>$EDITOR</code> set to first, and then fall back on <code>vi</code> otherwise.</p>
<p>The file is then saved to a temporary file and run when you exit, unless you do <code>%edit -x</code> (then it doesn't execute). While you're in your editor you can also write out to another file if you prefer.</p>
https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?comment=50035#post-id-50035When 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?Sun, 23 Feb 2020 03:44:59 +0100https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?comment=50035#post-id-50035Answer by tmonteil for <p>Is this possible? I want to work in Sage shell but I want to use VIM while typing up stuff in sage shell. </p>
https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?answer=42963#post-id-42963You can use any bash command by starting with `!`, in you case:
sage: !vim my_file.txtThu, 12 Jul 2018 16:41:42 +0200https://ask.sagemath.org/question/42962/running-vim-inside-sage-shell/?answer=42963#post-id-42963