Repeating a navigation command in vi - keyboard-shortcuts

How do I repeat a navigation command in vi?
For example, I execute the command 20j which moves the cursor down 20 lines, and I tried hitting . to repeat that command, but it says "No command to repeat".
P.S. Also, what command goes to the next page in a document?

There isn't a shortcut to repeat the last navigation command - you have to retype it, or set up some sort of shortcut of your own (:map or similar).
Page up (back) is Control-B; page down (forward) is Control-F. Half-pages are Control-U (up) and Control-D (down).

Related

Applescript to remove items from dock

I'm trying to remove (all) items from the dock. I can remove them by name like so:
tell application "System Events"
tell UI element "Launchpad" of list 1 of process "Dock"
perform action "AXShowMenu"
click menu item "Remove from Dock" of menu 1
end tell
end tell
But I'd like to pull the list of current items and iterate over them.
This stack overflow question seems to cover how to get the list. What I'd like to do is tweak the above code to operate inside of a loop. I would guess that referencing the current item of the list inside the loop would be done with "thisRecord". I think I'm misunderstanding how to convert "thisRecord" into something I can reference within system events.
set plistpath to (path to preferences folder as text) & "com.apple.dock.plist"
tell application "System Events"
set plistContents to contents of property list file plistpath
set pListItems to value of plistContents
end tell
set persistentAppsList to |persistent-apps| of pListItems
set dockAppsList to {}
repeat with thisRecord in persistentAppsList
set end of dockAppsList to |file-label| of |tile-data| of thisRecord
tell application "System Events"
tell UI element application thisRecord
perform action "AXShowMenu"
click menu item "Remove from Dock" of menu 1
end tell
end tell
end repeat
As an alternative... Here is a much more straight forwards approach to removing the persistent apps on the Dock found in the persistent-apps key of the com.apple.dock.plist file:
In Terminal, do the following to first backup the target file:
cd ~/Library/Preferences
cp -a com.apple.dock.plist com.apple.dock.plist.bak
Now to remove the persistent apps, use the following compound command:
defaults delete com.apple.dock persistent-apps; killall Dock
If later you want to restore the backup, use the following compound command:
cd ~/Library/Preferences; rm com.apple.dock.plist; cp -a com.apple.dock.plist.bak com.apple.dock.plist; killall Dock
If for some reason you need to do this with AppleScript, you can use the do shell script command to run these shell commands.
Note: In your OP you stated "I'm trying to remove (all) items from the dock." and the code you've presented only focuses on the apps stored under the persistent-apps key. There are also additional items that can show on the Dock, the first being the default persistent-others, which has the Downloads stack and other items you've added to that section. Then with macOS Mojave there is recent-apps which shows between the two aforementioned sections (by key name) on the Dock. The same premise can be use on these keys as well, substituting persistent-others or recent-apps for persistent-apps in the defaults delete ... compound command.
It would probably be wise to backup your "com.apple.dock.plist" file first. These following two lines of AppleScript code will copy your current com.apple.dock.plist file to your Desktop. This will come in handy if you want to revert your Dock icons back to the way they were before you ran the second script of this post.
set plistpath to (path to preferences folder as text) & "com.apple.dock.plist"
tell application "Finder" to duplicate alias plistpath to desktop
This AppleScript code works for me using the latest version of macOS Mojave.
set plistpath to (path to preferences folder as text) & "com.apple.dock.plist"
tell application "System Events"
set plistContents to contents of property list file plistpath
set pListItems to value of plistContents
end tell
set persistentAppsList to |persistent-apps| of pListItems
set dockAppsList to {}
-- Gets app names and adds them to dockAppsList
repeat with i from 1 to count of persistentAppsList
set thisItem to item i of persistentAppsList
set appName to |file-label| of |tile-data| of thisItem
set end of dockAppsList to appName
end repeat
-- Loops through each app in dockAppsList and removes each app from Dock
repeat with thisRecord in dockAppsList
tell application "System Events"
tell UI element thisRecord of list 1 of process "Dock"
try
perform action "AXShowMenu"
click menu item "Options" of menu 1
click menu item "Remove from Dock" of menu 1 of menu item "Options" of menu 1
on error
try
perform action "AXShowMenu"
click menu item "Remove from Dock" of menu 1
end try
end try
end tell
end tell
end repeat
I realize I could have included everything in one large repeat loop. I thought it would be better ,for purposes of this script, to separate the two looping events in the event that somewhere else in your script you may want to refer back to items of dockAppsList so instead of "removing all from the dock" you may only want to remove items 1 through 5 of dockAppsList from the dock.

Append Query Command Button

So I have used a command button to append data to a table in the past just fine, however this time, when I try to
CurrentDb.Execute "APPEND_DailyAbsenceInput"
I get the error
3061: Too few parameters
I feel that this is linked to the fact that I am trying to get a date which has been entered within a textbox. The bizare thing is, If I double click the query in the navigation panel, everything works just fine, however the command button throws up this error.

Move cursor to a new line after "Send Selection to Terminal" action in Geany

I set in geany a key shortcut to Send Selection to Terminal action which send the current line (or selection) to the build-in terminal (according to: shortcut to send selection to terminal in geany).
Then I change send_selection_unsafe=false to send_selection_unsafe=true in the geany.conf file (according to: Geany: execute line in Terminal)
Everything works well, I can send a line to terminal which is automatically executed. My problem is that at this point the cursor remains on the line after sending it to terminal.
Maybe I miss something, but is it possible to set or configure behaviour that cursor is automatically move to next line after using Send Selection to Terminal so than I can sending lines to terminal one after another (without hitting down arrow) ?
like this:
print("hello world!")
#I want cursor on this line after sending previous line to terminal, so this can be send to terminal immediately

IntelliJ IDEA find matching parenthesis / bracket

Is there any keyboard shortcut to navigate from one parenthesis ( to the matching one ) in IntelliJ?
Or even to "jump to the next opening/closing parenthesis (/) from wherever my cursor is"?
And, if there's no way to do it 'natively', are there any plugins that could add this functionality quickly and easily?
EDIT: the best solution I've found is added as a comment in liango's answer below, namely to put the cursor on the first or last brace and then press CTRL-W twice. Not ideal, but it does the job!
You can use Ctrl + [ and Ctrl + ] to navigate to a code block's start and end.
You can also use Ctrl + Shift + M to navigate between the start and end of a code block.
On Mac, you can use Option + Cmd +[ and Option + Cmd + ], and Ctrl + M
Source: https://www.jetbrains.com/help/idea/2016.2/navigating-to-braces.html
use CTRL-W to expand the selection within a bracket, use repeatedly if needed to select further out, then use the arrows.
CTRLSHIFTM is the Windows/Linux default shortcut for action "Move caret to matched brace". (For other environments see here and use the Shortcuts dropdown in the top right of the page.)
Or if desired, the shortcut keys can be changed as follows:
Go to Settings -> Keymap -> Editor Actions, or just type the name in the search box.
Here's the latest and greatest as of version 2020.1
To move caret between matching code block braces, press Ctrl+Shift+M.
To navigate between code blocks, press Ctrl+Shift+[ or Ctrl+Shift+].
From the documentation
Navigate with the caret
To navigate backwards, press Ctrl+Alt+← Left. To navigate forward, press
Ctrl+Alt+→→ Right.
To navigate to the last edited location, press Ctrl+Shift+Backspace.
To find the current caret location in the editor, press Ctrl+M. This
action might be helpful if you do not want to scroll through a large
file.
However, you can press the Up and Down arrow keys to achieve the same
result.
To highlight a word at the caret you are trying to locate, select Edit
| Find | Next Occurrence of the Word at Caret from the main menu.
To see on what element the caret is currently positioned, press Alt+Q.
To move caret between matching code block braces, press Ctrl+Shift+M.
To navigate between code blocks, press Ctrl+Shift+[ or Ctrl+Shift+].
To move the caret forward to the next paragraph or backward to the previous one, press Ctrl+Shift+A and search for the Move Caret Forward a Paragraph or Move Caret Backward a Paragraph action.
You can also select a text and then move the caret forward or backward to a paragraph. Press Ctrl+Shift+[ and search for the Move Caret Forward a Paragraph with Selection or Move Caret Backward a Paragraph with Selection action.
You can use Ctrl-[ and Ctrl-].

Showing the updates being performed by macro

So I have seen all the ways to hide the screen updating in excel, what I'm looking for is a data problem, so I WANT to see the screen update. Is there a way to code the screen to update during the macro slowly? I tried the following:
'//////adding screen updating to watch what's happening
Application.ScreenUpdating = True
Application.Wait Now + TimeValue("00:00:01")
'/////
and all I got was screen flicker.
Thanks for being excellent unto me.
What you're after is a better method of debugging your errors. ScreenUpdating property of the Application is not what you want :)
Instead, set a breakpoint in your code using F9, at or before where you suspect the error is happening. If necessary, you can put this on your first line of code (if you literally have no idea where the error happens).
Here is a breakpoint, it's the red/maroon highlighted line:
Then, using the F8 key, you can step through the code line by line.
You can add as many breakpoints as you want. Pressing F5 will execute the code only up to the next breakpoint, then you would have to F8 or F5 to resume execution.
Some additional things to help you debug
Use the Locals window.
This shows you the vairables in scope, and you can click on them to view their properties/etc. As you can see, I have a shitload of variables in a fairly complicated application. I've found the immeidates window is very helpful for Object variables and arrays. Here is what it looks like when I expand an array variable, so that I can see all its contents:
Use the Immediate window to query variables or execute statements outside of your code, this is equivalent to Debug.Print statements. For example, let's check to see if the value of some variable is "9", you can:
?someVar = 9 and then press enter. It will show you True or False. You could query the value directly by ?someVar and it would print the value.
In this screenshot, I am checking the value of a boolean, and it shows me that the value is False. I could also verify this in the Locals window.
The screen updating must be set only once, at the start of the code.
But the Wait you will need to put inside your loop, or spread between your code lines.