I am trying to run latex in Vim (without leaving normal mode) in the following way:
Open the document.tex in vim
Compile the .tex file and turn it into a .pdf file. I do this with :! pdflatex %
View the pdf file. I do this with :! %<.pdf
This does show the pdf file (in ms edge) but the command line of Vim is locked: I can't do anything at all until I close the pdf file viewer. This is uncomfortable because, while I only need to compile from time to time, I want to keep the pdf open when correcting mistakes
Why doesn't :! %<.pdf work? Why does the cmd (I'm running this on Windows) "keep running" the command? How can I fix this?
Related
I have been trying to add my SSH keys to the ssh-agent by following the directions on this GitHub doc: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key
This is what I put into the terminal:
root#Nicoles-MacBook-Air nicoletr # eval "$(ssh-agent -s)"
Agent pid 21417
root#Nicoles-MacBook-Air nicoletr # open ~/.ssh/config
The file /var/root/.ssh/config does not exist.
root#Nicoles-MacBook-Air nicoletr # touch ~/.ssh/config
root#Nicoles-MacBook-Air nicoletr # open ~/.ssh/config
But when I hit enter to open the ~/.ssh/config file, the TextEdit app opens instead of a text file that I can modify. I am supposed to modify the config text file but I don't even see any file at all. I am still very new to coding so I would be extremely grateful for any guidance.
Open command
On MacOS, the open command will open file in parameter with the default configured application for this filetype (such as Preview, TextEdit or Safari for some others)
Even though you can override which application is used to open the file, there are more standard solutions to achieve this.
For the sake of completeness, you can override default app by using -a option, for example, if you want to open an html file with TextEdit instead of Safari by default:
open -a TextEdit page.html
More information about open:
Article on scriptingosx.com
Open man page
Alternative
If you would like to edit any file directly from your terminal, you can use packages such as nano, to easily get started with it you can check this article. As an added bonus, it also go through setting brew to easily install package, also from your terminal
There are alternatives to nano (like vi, vim) and to brew (such as macports). They all have their pros and cons depending on the use, though in you case, I don't think your need would justify the steeper learning curve yet
Happy discovering coding !
When I use the idea command line tool to open a file in LightEdit mode
$ idea myfile.txt
and IDEA is already open in project mode it will not open file file. IDEA gets focus but the file does not open.
However, when I used the idea command line to open a file in LightEdit mode and IDEA is not already open, it works as expected.
If you use the Create Command-line launcher option to recreate the idea launcher file it will start working as expected.
I built a quite large PDF using LaTeX with the lualatex compiler (I need that one because of specific fonts) and now want to shrink the PDF with ps2pdf, following this instruction (the answer with the second-most votes, since gs is not recognized as a command line tool on my computer). My command looks like this:
ps2pdf -dPDFSETTINGS=/ebook -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -q -sOutputFile=output.pdf input.pdf
I get this error message:
MiKTeX GPL Ghostscript 9.25: Device 'pdfwrite' requires an output file but no file was specified.
**** Unable to open the initial device, quitting.
I definitely made sure that the file exists, I tried it using as *.ps file as input, gave the full path, once with and without double-quotes (Windows system), yet nothing worked. Strangely enough, just running ps2pdf ouput.pdf input.ps works, but produces an even larger PDF. What am I missing?
The file that can't be opened is the output file, so if it exists, that would be a potential problem. If 'something else' has the output file open then it won't be possible to write to it.
You appear to be running a non-standard version of Ghostscript, judging by the startup banner, if I were you I would install and use a standard version of Ghostscript, even if you have to build it yourself.
It's odd that 'ps2pdf' which is just a script to run Ghostscript would work, whereas a simple 'gs' would not. I personally would not use the script. Try and find the Ghostscript executable and run that directly.
I'd drop the -q (quiet) switch as well, at least while trying to solve a problem, suppressing messages could be hiding something useful.
Oh I see, you are actually using Windows. Well, the executable on Windows isn't called 'gs', it's called gswin followed by either 32 or 64 for the word size and then c if it's the command line (as opposed to windowed) version. So you want one of gswin32, gswin32c, gswin64 or gswin64c. Note that the Ghostscript installer doesn't add the installation directory to the $PATH environment variable so if you just open a Windows command shell and type 'gswin32c' it won't be found. You need to either add the isntall directory to the $PATH or supply a full path to the executable.
I'd personally use the vanilla Windows binary rather than a modified version supplied under MingW or whatever Linux shell you are using. It's also conceivable that this is causing your problem writing to the output file, if the directory is unavailable, or read-only, to the shell.
I am creating latex documents on Linux (Debian 9) writing them in markdown and converting them with pandoc.
I use the following pandoc terminal command:
watch -n 5 pandoc -N --toc --toc-depth=3 -f markdown checklist.md -t
latex -o checklist.pdf
which compiles the markdown code into a pdf (latex) every 5 seconds, which enables live preview.
The issue is that the pdf in the pdf reader (i have tried several, i.e. evince, atril, okular, mupdf) flashes every time the pdf is recompiled (in this case every 5 seconds), which is somewhat annoying.
I had a similar setup for latex live preview in vim, and it was not flashing like this.
(one possible difference between the vim setup, and my current workflow, is that in vim, the latex code would auto-save after any changes, which i am not doing now (and would rather not do).
PS: i have found this script, that seems interesting, but am not sure how to get it to work:
https://gist.github.com/mmcclimon/7311538
I am using the pdflatex compiler in TeXnicCenter, I wanted to be able to change the output file name, without changing the .tex file name, so I used this line at the start of my file:
%&pfdlatex -job-name=newfile
This method works well, but the compiler doesn't open the pdf automatically anymore, Is there any Command I could use in Viewer instead of the default DDE command to do the job? this is the current command:
[DocOpen("%bm.pdf")][FileOpen("%bm.pdf")]