How can I create a toggle to completely show/hide the line number gutter? - neovim

I'd like a shortcut of some kind to toggle between the following:
set norelativenumber nonumber signcolumn=no
set relativenumber number signcolumn=yes
I'm pretty new to nvim, thanks for any suggestions

Something like this will work:
function toggle_stuff()
-- sort of a "ternary" operator in lua
vim.o.signcolumn = vim.o.signcolumn == "yes" and "no" or "yes"
vim.o.relativenumber = not vim.o.relativenumber
end
And then, to map it on t + s combination in a normal mode:
local map = vim.api.nvim_set_keymap
local default_opts = {noremap = true, silent = true}
map('n', 'ts', ':lua toggle_stuff()<CR>', default_opts)

Related

Search for text in Word Endnotes

Hello: I am trying to perform either a regular search or wildcard search in Word, specifically in the Endnotes.
Here is what I am searching for:
[Endnote Reference][space][text....][:]
Here is an example of what the endnote might look like:
12 Text in my endnote ending with a colon: More text but not what I want.
So what I want to do is select all the text (plus colon) following the Endnote Reference + space (i.e., Text in my endnote ending with a colon:) and add bold/italics.
I've tried using the advance search where I search for:
^e^?: --> doesn't work (I'd like to make the "any character" a bunch of characters until the : is reached)
Wildcard search does not allow the use of ^e so I tried:
*L --> that gives way too much and then also doesn't work.
Any feedback is much appreciated. I could accomplish this in Perl, but not in Word.
thanks in advance!
You don't need Regex for this. All you need is a wildcard Find, where:
Find = ^2 [!^13]#:
Using VBA for what you're trying to do:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.StoryRanges(wdEndnotesStory)
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^2 [!^13]#:"
.Replacement.Text = ""
.Forward = True
.Format = False
.Wrap = wdFindStop
.MatchWildcards = True
End With
Do While .Find.Execute
.Start = .Endnotes(1).Range.Start
.Style = "MyBoldItalicCharacterStyle"
.Collapse wdCollapseEnd
Loop
End With
Application.ScreenUpdating = True
End Sub

Microsoft Word macro for highlighting 500+ words, with no limit to TargetList

I've tried using the code shared in this stackoverflow thread about creating a macro that highlights specific words, and that code works for up to 68 words and phrases, but then it seems like I reach a limit and it won't allow me to enter additional terms. I need to be able to search for and highlight 500+ terms.
Is there normally a limit to search terms? Or is there a way for me to refer the macro to a separate document that contains all the words I want it to identify, as opposed to entering each term into the code? Thanks very much for any guidance.
I have already tried this code with up to 68 targets, at which point the code stops letting me enter new terms:
Sub HighlightTargets()
'
' HighlightTargets Macro
'
'
Dim range As range
Dim i As Long
Dim TargetList
TargetList = Array("target 1", "target 2", "target 3", ... "target 68")
For i = 0 To UBound(TargetList)
Set range = ActiveDocument.range
With range.Find
.Text = TargetList(i)
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute(Forward:=True) = True
range.HighlightColorIndex = wdYellow
Loop
End With
Next
End Sub

How to delete all text after certain character in MS Word?

let's say I have text like this:
Something something: what what what
another something something: another whhaa
So I want to delete text after character : on each line, so I end up with:
Something something
another something something
is that possible?
It's possible, but if we're talking about lines (as opposed to paragraphs) not 100% reliable. Word doesn't consider a "line" as a tangible object since it's always recalculating the page flow (where things break across lines/pages). Paragraphs are objects since ANSI 13 defines the end of a paragraph.
Here's some VBA code that demonstrates the literal interpretation of your request. The part through Find.Execute was made by recording using Word's Find functionality. The last three lines extend the selection to the end of the current line, move it back by one character to leave the new line / end of paragraph intact. then delete the selection. This should give you a starting point.
Selection.Find.ClearFormatting
With Selection.Find
.Text = ":"
.Replacement.Text = ""
.Forward = True
.wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.CorrectHangulEndings = False
.HanjaPhoneticHangul = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveEnd wdLine, 1
Selection.MoveEnd wdCharacter, -1
Selection.Delete

redirect input standard MATLAB

From Matlab I call a system command and this command will ask to enter yes or no. How could I redirect to input ?
I've tried:
myCmd = fullfile('control','bin','launch');
cmd = system(myCmd);
=> this will ask following message to enter yes /nos (prompt)
so I've tried
cmd = system([myCmd ,' < ','yes'])
but this is not working.
You can use input function provided in matlab. result = input(prompt) displays the prompt string on the screen, waits for input from the keyboard. More about it here. Hope this helps you.
To request a simple text response that requires no evaluation.
prompt = 'Do you want more? Y/N [Y]: ';
str = input(prompt,'s');
if isempty(str)
str = 'Y';
end

How to save web page content to a text file

I use an automation script that tests a browser-based application. I'd like to save the visible text of each page I load as a text file. This needs to work for the current open browser window. I've come across some solutions that use InternetExplorer.Application but this won't work for me as it has to be the current open page.
Ideally, I'd like to achieve this using vbscript.
Any ideas how to do this?
You can attach to an already running IE instance like this:
Set app = CreateObject("Shell.Application")
For Each window In app.Windows()
If InStr(1, window.FullName, "iexplore", vbTextCompare) > 0 Then
Set ie = window
Exit For
End If
Next
Then save the document body text like this:
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("output.txt", 2, True)
f.Write ie.document.body.innerText
f.Close
If the page contains non-ASCII characters you may need to create the output file with Unicode encoding:
Set f = fso.OpenTextFile("output.txt", 2, True, -1)
or save it as UTF-8:
Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Type = 2 'text
stream.Position = 0
stream.Charset = "utf-8"
stream.WriteText ie.document.body.innerText
stream.SaveToFile "output.txt", 2
stream.Close
Edit: Something like this may help getting rid of script code in the document body:
Set re = New RegExp
re.Pattern = "<script[\s\S]*?</script>"
re.IgnoreCase = True
re.Global = True
ie.document.body.innerHtml = re.Replace(ie.document.body.innerHtml, "")
WScript.Echo ie.document.body.innerText