To knit an external pagedown rmd file to a pdf - pagedown

Is it possible in a pagedown rmd file to call and knit an external pagedown rmd file?
I tried rmarkdown::render() in an r code chunk. It did not work.

Related

How to view zst file using Vim?

I'm trying to view some log files in zst format. I can use zstdcat to view the content, but when I do vim <filename.zst>, there're only garbled text. Is there a similar way as zstdcat to view zst file with Vim as well?
You use Zstandard to compress data so a *.zst file is not readable text and there is no point opening it directly in a text editor. You will have to decompress it first, which is what zstdcat does:
zstdcat is equivalent to zstd -dcf
and then open the decompressed text in Vim.
To view the content of a *.zst file in Vim, from your shell:
$ view <(zstdcat filename)
$ zstdcat filename | view -
To view the content of a *.zst file from Vim:
:enew | r !zstdcat filename
Note that, in both cases, you are not viewing the *.zst file itself but a copy of its decompressed content.
Of course, the whole thing could be streamlined and turned into a plugin similar to :h zip.

vim: recovering a text file "already at oldest change"

I am using vim to edit .sh file. Last time, I was making changes I got: "E297: Write error in swap file" and I accidentally managed to erase the content and save.
Now, all I have is .sh .sh~ .su~ .sv~ .sw~ .sy~ .sz~ files with empty content and "E297: Write error in swap file" message. When I do :u, it says: "already at oldest change".
when I do :recover, it says: "E305: no swap file found"
How to recover my file? thanks
In this case, the original file may be recovered using swap files which have the form .filename.sh.swp. These are files that Vim creates to back up in case of a potential crash. In order to recover your original file, try these steps:
Look for swap files in the current directory (there could be more than one for a particular file):
ls -a
Open the first swap file in Vim from the terminal:
vi .filename.sh.swp
or alternatively, launch Vim with vim and edit the swap file with :e .filename.sh.swp.
From within the swap file type :recover. Now Vim will load the recovered file on a new buffer. If this is the file that you needed then simply save the file :w.
It could be that the recovered file is not exactly the latest version of your filename.sh, in this case repeat steps 2 and 3 above with a different swap file e.g. .filename.sh.swo. Once the desired file has been recovered removed the swap files.
These help pages are also relevant for recovering files:
:help swap
:help recover
:help e305

VIM open c++ header file in vertical split by combining three commands

I have indexed my c++ codebase with ctags, I can open a header file as follows:
:tag myfile.h
(It doesn't matter where myfile.h is located, as long as it is inside the indexed codebase it will open correctly in vim)
When I'm editing a c++ file, I can get the header filename as follows:
:e%<.h
e.g. when editing myfile.cpp, executing this command will display myfile.h on the command line.
A file can be opened in vertical split, by issuing:
:vs <myfile>
Now what I want to accomplish, is to have 1 command or function which I can use to open a header file of the corresponding c++ file that I'm currently editing in vertical split. Hence basically I want to combine the 3 above commands as if I would be doing a Unix pipe, e.g.:
:vs tag | e%<.h
" :vs to open file in vertical split
" :tag to find tag
" :e%<.h to get header filename
Obviously the Unix pipe doesn't work on vim, alternatively I've tried to write a function at which I assign the result of a command to a variable, e.g.
headerFileName = :e%<.h
Which apparently is not the correct way of doing this, I'm a bit lost here so I hope somebody can provide some help.
There exist several plugins that already do this (without needing a ctags database BTW).
For instance, with alternate (aka a.vim), you just have to type :VS from the header file or the source file to open the other one in a vertically split window.
Note that alternate have an option to tell where to find the other file (same directory, substitute on directory name, ...)
Otherwise, I suspect you are looking for expand() and :exe. If you write a function it may be
function! s:whatever() abort
let crt = expand('%:t:r')
vnew
exe 'tag '.crt.'.h'
endfunction
command! whatever call s:whatever()

How to link to another file in vim?

I downloaded the DrawIt plugin to draw a diagram in vim. I successfully installed that plugin.
Then I found DrawIt.vba file in my home directory and opened the file. It had the following content:
" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.
UseVimball
finish
+-- 67 lines: plugin/DrawItPlugin.vim--------------------------------------------
+--484 lines: plugin/cecutil.vim ------------------------------------------------
+--1662 lines: autoload/DrawIt.vim-----------------------------------------------
+--401 lines: doc/DrawIt.txt-----------------------------------------------------
In that file, I placed the cursor in the + (plus) and I pressed the right arrow key(->).
It opens the specified path (plugin/DrawItPlugin.vim) of the file.
I really wonder about that one.
I want to create something like this. I searched in NET, but I didn't get any proper way to do it.
Can you help me do this?
Actually, that is not what is happening.
"Vimball" files are archive type files that contain number of other files in them. When you "source" such file, Vim extracts these files into specified paths, for example the content under plugin/DrawItPlugin.vim will get extracted into a file with that name inside your $VIM directory.
What you actually describe is an example of folding. Vim can "fold" parts of a file, so that they are hidden, and replaced by just one line.
+-- 67 lines: plugin/DrawItPlugin.vim--------------------------------------------
means that there is 67 lines of hidden content, starting with the text plugin/DrawItPlugin.vim. When you navigate the cursor into this text, it gets unfolded.
Type :he folding in Vim to read the Vim help on folding.
You can "jump" to a file whose path is under cursor with gf (goto file). Type :he gf for details.
Finally, using the "VimWiki" plugin, you can create files that link to other files, in a Wiki fashion.

Save file with new filename: append to existing filename

Is there a simple way to (in VIM) do save the currently open file with it's current name plus an appended phrase?
IE, from /home/affert/ type vim /data/folder/file1.txt
then save the file as /data/folder/file1.txt_BACKUP without needing to copy and paste the filename?
Context: I have a file that has full paths in it to other files in other folders. I use ctrl+W, ctrl+F to open the file in a new window. That's why I don't want to copy and paste. BTW, the folder and file names are a lot longer, so typing them myself is not a useful option.
:w %:p_BACKUP
For explanation see How can I expand the full path of the current file to pass to a command in Vim?.
Easy:
:w %_BACKUP
If you need override:
:w %_BACKUP!
The it gonna answer:
"filename_BACKUP!" [New] XL, XC written

Resources