Google Apps Script - ReplaceText vertical tab - regex

Whenever I paste text into a Google Docs document, all the newline characters get convereted into vertical tab characters (\013 OR \v). This happens regardless of the source of the clipboard text (webpage, word, notepad++).
Usually this means I have to work my way through the document clearing all the vertical tabs and replacing them with proper newlines by backspacing the character and hitting return. However, I want to write a script to replace all the characters in the doc at once. The Replace ui feature doesn't support newline characters but I'm hoping the scripting api does.
I have written the code below, but though it runs, the vertical tab characters are not replaced. I can still see hundreds in the document with the find/replace ui feature. What am I doing wrong?
function myFunction() {
var body = DocumentApp.getActiveDocument().getBody();
body.replaceText("\\v", "\n");
}

Related

Dataprep - accents and special characters

How do I solve this problem with accents / special characters in the dataprep? I need this information to appear.
Thank you very much for your attention.
DataPrep has builtin recipes which allow you to remove or change special characters. For example, you can change accented letters to unaccented ones with Remove accents in text or you can also replace non recognised characters for another character with Replace text or patterns.
Below are the steps to change a special character or accented letter.
Create your flow.
Add/import your data
Click Add a recipe, as per documentation. In your case you can do one or both of the following:
First, in case you have an accented word, go to Search Transformations > Select Remove accents in text. Then, select the column, which there are accented words. It will replace the accented words for non-accented ones. Your data your be shown to you so you can check the transformation.
Second, in case you have an non recognised character, go to Search Transformations > Replace text or patterns > Select the column you want to transform the data > Within Find write the letter/symbol between single quotes > In Replace with write the letter which will be placed instead. Finally, preview your data to see the transformation.
UPDATE: I was able to load a .csv file with the mentioned characters to DataPrep. Below are my steps and sample data:
The .csv file I used had the following content:
Test
Non rec. char É
Non rec. char ç
Accented word não
In the DataPrep UI home page, click on Import Data (top right corner) Google Cloud Storage (left part of the screen). Then, find and select you file (test just importing one file instead of parametrizing) and click in the add(+) symbol. In this step, you can already see the characters, in my case I could see them normally. Finally, click in Import&Wrangle and visualise your data. Using the data above, I was able to see the characters properly without any issues.

Dot character cancels completion in Sublime Text plugin

I'm working on a Sublime Text 3 plugin, which contains a number of completions for the standard library. Some of these functions (e.g. io.open( filename, mode )) contain the dot character (".").
The problem is, Sublime Text cancels the completion dialog when a "." is typed (word boundary).
To get around this, I've tried using underscores instead of dots in the triggers:
{"trigger": "io_open( filename, mode )", "contents": "io.open( ${1:filename}, ${2:mode} )"}
However, this doesn't work very well at all. If the user tries to type in io.open instead of io_open, Sublime restarts the completion at the dot, and they end up with io.io.open.
Is there any way around this? Having the dot character as word boundary is useful for selecting text, so I'd like to keep that if it is possible.

Moving over tab spaces in ncurses

I am creating a basic text editor using ncurses. It can display text fine, but navigating with arrow keys causes a problem when tabs are encountered. Calling move(y, x) will freely move the cursor onto a tab space, where most text editors will jump to the next character. Is there functionality within ncurses to jump over tab spaces or do I need to find a way to do it myself?
You have to do it yourself: wmove moves to the given coordinates, ignoring the way characters are displayed on the screen.
If a destructive (filling with spaces) tab works for your application, then you could use waddch:
If ch is a tab, newline, carriage return or backspace, the
cursor is moved appropriately within the window:
Tabs are considered to be at every eighth column. The
tab interval may be altered by setting the TABSIZE
variable.
For an editor, you probably do not want that behavior (though it probably would be helpful to use the TABSIZE feature when displaying text).

Move insertion point to the beginning of the blank line between paragraphs MS Word

I often need to translate a document in MS Word and I do it paragraph by paragraph, the translation text follows each individual paragraph of the original text. What I need is a keyboard shortcut to move the insertion point to the blank space after the following paragraph I need to translate, i.e to move the cursor from the end of the red colored text in the picture to the blank space after the following paragraph ending with "..and call it a day"
Ctrl+Down Arrow shortcut in Word places the insertion point at the beginning of every following paragraph, while I need it placed at the beginning of the blank line above it so I can immediately start typing.
I am looking for a Word shortcut key, regex expression or an autohotkey script that could perform this task, it would come handy to me in doing translation in MS Word.
Thank you for the help!
On MCL's suggestion I've created a simple Autohotkey script to solve the problem, combining Word keyboard shortcuts into one. I also added a code from another script which sets dark red color of the text which is being typed into the original document to make the contrast with the default text color of the original. This is a convenient option for translators which also allows saving only the translated text by using Find function in Word, and removes the need for any further editing of the translated document. Here's the script:
#IfWinActive ahk_class OpusApp
^2::
Send ^{Down}
Send ^{Down}
Send ^{Left}
Send {Enter}
{
oWord := ComObjActive("Word.Application") ; MS Word object
wdColorDarkRed = 128
oWord.Selection.Font.Color := wdColorDarkRed
}
return

How to programmatically Paste CSV text into Excel and not just go into one cell? (C++)

I have a list/grid in an MFC (c++) application. I would like the user to be able to copy and paste the data into a spreadsheet.
I've placed the data in the clipboard and the text makes it to the clipboard ok and I can paste it to notepad or Word or Excel, but Excel does not interpret the comma separated value-ness of my clipboard content - so it just goes into one cell/one column - rather than doing what I had hoped.
I hope there is something simple I am missing.
Any suggestions to get this to work?
I am not quite ready to make this a drag/drop source (which is in the task list)
EDIT:
I have it working - commas can't be used - must be tab separators
But now there is a new problem:
The issue now is that if I paste to excel using '\n' as line separator it looks good in excel but not in notepad.
If I make it "\r\n" then notepad looks correct but excel then has blank lines.
Any suggestions on how to make both consistent?
I used this question and tabs seem to work - but csv still does not
How to paste CSV data to Windows Clipboard with C#
Well, here's my two cents..
It seems a tab character in an NSString, such as #"123\t456" would tell Numbers and OpenOffice spreadsheets, that 456 goes into the next cell of the same row.
Likewise, a newline character \n, or a carriage return \r, would put follow-up data on a new row, for example #"123\n456" or #"123\r456" would put 456 in the next row (starting with the first column from the left).
Indeed, TextEdit does not interpret the newline (\n) or carriage return (\r). (OpenOffice text documents do.)
However, providing the pasteboard with an array of strings (be it NSStringPBoardType, or NSRTFPBoardType, or whatever), puts the different strings on seperate rows, both in a spreadsheet and in TextEdit.
Also, a tab (\t) shows up as a tab in TextEdit, which you can then manipulate in the toolbar, to get a nice layout of your data.