How can I change the Heading Number with VBA code?
For example, "1.1 Computer system"
I'd like to change "1.1" to "1.2".
I can read it with:
Selection.Paragraphs(1).Range.ListFormat.ListString
I can't find a way to change it.
Basic Function Test
1.1. LED Function Test Purpose: To make sure all the LED Functions are working as the Product Specification Resource Requirements:
The context is shown above. Sometimes, I copy from another document. The pasted heading number is not correct.
I tried to record the macro but the recorded macro is empty.
To force Heading 2 to start the numbering from 1.2, all you need is:
ActiveDocument.Styles(wdStyleHeading2).ListTemplate.ListLevels(2).StartAt = 2
Your update shows you're trying to do something quite different, however.
The only reliable way to retain the original numbering when copying/pasting between documents is to either:
convert the source numbering to static text before copying; or
paste the copied content as unformatted text.
Hello I want some help with a code to search through the text file and to separate the text from a separator value followed by a rogue(stopping) value.
Each line of text in the text file is: for example with sample data:
DAC11010|This is a Desk and a chair|$100;.
In the above example has the | sign as a seperator value and ;sign as a rogue(stopping) value. The separator value separate the text DAC11010 , This is a Desk and a chair , $100 the rogue(stopping) value means that it it is the EOLN(end of line) and ready to check the next line.
The separated text goes to 3 ListBoxes and the data added one after the other. The DAC11010 goes to the lstItemCode , This is a desk and chair goes to the lstDescription , $100 goes to the lstPrice.
I would like if someone would volunteer to help me program the code in vb.net. I hope I made myself clear.
Thank you [shannon].
If you haven't already done so, please turn on Option Strict. This is a 2 part process. First for the current project - In Solution Explorer double click My Project. Choose Compile on the left. In the Option Strict drop-down select ON. Second for future projects - Go to the Tools Menu -> Options -> Projects and Solutions -> VB Defaults. In the Option Strict drop-down select ON. This will save you from bugs at runtime.
I will not write the code for you. That is not the purpose of Stack Overflow. We help with specific problems you are having with your code. You don't appear to have any code.
I will explain one way your goal might be accomplished.
Declare 3 New List(Of String) variables to hold the data for the three list boxes. We will be looping through the text files lines but we don't want to update the user interface until after the loop so we will collect the data in memory.
You will need to import System.IO to use methods of the File class. You can use File.ReadAllLines to get an array of strings; each member of the array will contain one line from the text file.
Next, you will want to loop through the lines splitting each line into 3 sections. Use the For Each...Next type of loop. You can use the String.Split method passing in your "|"c parameter. The c tells the compiler that this is a Char not a string because .Split is expecting a Char Now you can use the .Add method to add the sections to the appropriate list.
After the loop, you can assign the 3 list to the .DataSource property of the appropriate ListBox.
Now write the code and if you have any problems ask a new question showing the specific code where you are having the problem.
Background
I want to be able to select some text, hit a keystroke that pastes what is on the clipboard over that selection, but at the same time copying that selection to the clipboard. I often find myself doing this operation when switching variables, etc from place to place.
Example
First sentence here, I need to switch it with the second sentence below. (ctrl-c)
...
Second sentence here, I am going to put this where the first one is.
///////
First sentence here, I need to switch it with the second sentence below.
...
First sentence here, I need to switch it with the second sentence below. (ctrl-"vc" after selecting second sentence, first sentence pasted, second sentence copied now)
///////
Second sentence here, I am going to put this where the first one is. (ctrl-v)
First sentence here, I need to switch it with the second sentence below.
My question
Does anyone know if any IDE/software supports such a paste/copy functionality? Has anyone ever run into this?
More specifically, does any one know how to set up a keyboard shortcut to do this in sublime text 2?
You can do it with a plugin. I threw this together rather quickly. I don't do anything special for multiple cursors (though it should take the content of multiple cursors as well as paste to all the proper locations).
import sublime
import sublime_plugin
class PasteAndCopyCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
current_content = []
cursors = view.sel()
for cursor in cursors:
current_content.append(view.substr(cursor))
for cursor in cursors:
view.replace(edit, cursor, sublime.get_clipboard())
sublime.set_clipboard("\n".join(current_content))
After you save the plugin, use paste_and_copy as the the command for your key binding or command palette entry.
If I select a variable (not just any string) in my code, all other instances of that variable get a stroke (white outline) around them:
Is there a keyboard shortcut that will let me select all of those instances of the variable and edit them all at once?
Things I've Tried:
⌘D, ⌘K, and ⌘U lets me select them one-by-one, but I have to manually exclude the non-variable string matches:
And using Ctrl⌘G simply selects all the string matches:
Clearly, Sublime is able to differentiate between variable and string matches. Is there no way to select just the variable matches?
Put the cursor in the variable.
Note: the key is to start with an empty selection. Don't highlight; just put your cursor there.
Press ⌘D as needed. Not on a Mac? Use CtrlD.
Didn't work? Try again, making sure to start with nothing selected.
More commands:
Find All: Ctrl⌘G selects all occurences at once. Not on a Mac? AltF3
Undo Selection: ⌘U steps backwards. Not on a Mac? CtrlU
Quick Skip Next: ⌘K⌘D skips the next occurence. Not on a Mac? CtrlKCtrlD
Sublime Docs
I know the question is about Macs, but I got here searching the answer for Ubuntu, so I guess my answer could be useful to someone.
Easy way to do it: AltF3.
Despite much effort, I have not found a built-in or plugin-assisted way to do what you're trying to do. I completely agree that it should be possible, as the program can distinguish foo from buffoon when you first highlight it, but no one seems to know a way of doing it.
However, here are some useful key combos for selecting words in Sublime Text 2:
Ctrl⌘G - selects all occurrences of the current word (AltF3 on Windows/Linux)
⌘D - selects the next instance of the current word (CtrlD)
⌘K,⌘D - skips the current instance and goes on to select the next one (CtrlK,CtrlD)
⌘U - "soft undo", moves back to the previous selection (CtrlU)
⌘E, ⌘H - uses the current selection as the "Find" field in Find and Replace (CtrlE,CtrlH)
This worked for me. Put your cursor at the beginning of the word you want to replace, then
CtrlK, CtrlD, CtrlD ...
That should select as many instances of the word as you like, then you can just type the replacement.
The Magic is, you have to start with an empty selection, so put your cursor in front of the word/character you want to multi-select and press Ctrl+D .
To me, this is the biggest mistake in Sublime. Alt+F3 is hard to reach/remember, and Ctrl+Shift+G makes no sense considering Ctrl+D is "add next instance to selection".
Add this to your User Key Bindings (Preferences > Key Bindings):
{ "keys": ["ctrl+shift+d"], "command": "find_all_under" },
Now you can highlight something, press Ctrl+Shift+D, and it will add every other instance in the file to the selection.
As user1767754 said, the key here is to not make any selection initially.
Just place the cursor inside the variable name, don't double click to select it. For single character variables, place the cursor at the front or end of the variable to not make any selection initially.
Now keep hitting Cmd+D for next variable selection or Ctrl+Cmd+G for selecting all variables at once. It will magically select only the variables.
It's mentioned by #watsonic that in Sublime Text 3 on macOS, starting with an empty selection, simply ⌃⌘G (AltF3 on Windows) does the trick, instead of ⌘D + ⌃⌘G in Sublime Text 2.
At this moment, 2020-10-17, if you select a text element and hit CTRL+SHIFT+ALT+M it will highlight every instance within the code chunk.
Just in case anyone else stumbled on this question while looking for a way to replace a string across multiple files, it is Command+Shift+F
I have several hundred short mp3 files (1-5 seconds) I would like to trim them. namely, the length should be rounded up getting a whole second. for example if a mp3 file is 1.32s long, it should be afterwards 2.00 in length, the lack of time should be filled with silence. is it possible to automate this process? if so with what tool? thanks
Try Audacity, it allows batch processing: http://manual.audacityteam.org/index.php?title=Batch_Processing
I'm not sure whether it will do everything that you need it to do but it's worth checking out what all your options are within this program.
[EDIT]
Ok, so if you do have hundred and also might be something useful for you in the future this is what I would recommend or would personally do myself.
Get mp3DirectCut [freeware]
Get AutoHotKeys [freeware]
Learn how to use both, particularly AutoHotkeys
Save All filenames into a spreadsheet
Create a script that does the following with mp3DirectCut
Load file by name on spreadsheet
Hit the "End" button
Paste a pre-copied silent 1 sec long clip from clipboard
Parse the NAV field in the program (bottom left) to get the Total length
Calculate and enter desired endpoint to total length for Selection (then hit Enter)
Hit the "Del" button
Save complete song
Repeat