Move/Copy the active line OR selected text to another file #171
Replies: 7 comments 4 replies
-
Is it doable to add context by using dialog? like I want to move Then I want to add text
to another file. OR Move text to another file and then insert text above it and below it? Depends on you |
Beta Was this translation helpful? Give feedback.
-
Update v1.6.2 - Fixed removing of line on "move" as new Templater update changed the way it clears the line text. https://gist.github.com/GitMurf/fc4132acd805b9c1413ab84c6bd11576 |
Beta Was this translation helpful? Give feedback.
-
thanks for this script! it actually solves some problems for me :) One minor issue that I noticed with the script: If you currently have text select (e.g. after highlighting a text passage with |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for this, it handles almost al scenarios I was thinking about. If I may suggest, one last mode that could complement this template will be to send a block reference to a target file instead of sending the block from current file to target file leaving a block reference in current file (as it is achieved by the |
Beta Was this translation helpful? Give feedback.
-
Great job! Just what I was looking for, thank you! :) It would be great to have an option to force the target note to today's note. So you don't have to choose it from the GUI. I use to "bring" past meeting minutes to today's notes. What do you think? |
Beta Was this translation helpful? Give feedback.
-
The last post was a while ago. I had an out of bounds error with the first instance of the line so I changed it to
|
Beta Was this translation helpful? Give feedback.
-
Hey just went over the code as I currently want to support a workflow to extract to a new node including a template (see discussion). This templates supports me in understanding how things are meant to be! Increase reusability
I recommend you to do it differently for better maintainability. Maybe this is also a great update for your tutorial on how to use templater.
/** usage:
*
* tp: templater object to use
* firstOrLastLine: 'first' will add to top of file. 'last' will add to bottom of file
* bChooseLine: choose a specific line to move to underneath; overrules firstOrLastLine if true
* bOpenFile after moving the line, open the file it was moved to
* mobeMode: /"move" = default, "copy" = duplicate, "embed" = move and leave a block ref link, "blockRef" = create block ref and add **/
async function move_file (tp, firstOrLastLine, bChooseLine, bOpenFile, moveMode) {
// your content without the header to steer functionality
}
module.exports = move_file;
<%* await tp.user.move_file(tp, 'first', false, false, 'move') %> Edit: Checked how this works for my own template. Following notes:
|
Beta Was this translation helpful? Give feedback.
-
https://gist.github.com/GitMurf/fc4132acd805b9c1413ab84c6bd11576
Demo: https://user-images.githubusercontent.com/64155612/116498977-e575e380-a85f-11eb-9333-14b16cf18982.mp4
Move or Copy the active line (or selected text) of the active file to a chosen file.
Change the
const moveMode = "move";
to your choice. I recommend making multiple templates with the same code and then just changing this variable for the different "modes" outlined below.Now can do the following:
Beta Was this translation helpful? Give feedback.
All reactions