For example:
const greet = 'Hello!'
I want to change the single-quotes to double-quotes...
const greet = "Hello!"
...where I just select/highlight the first single-quote and overwrite it with a double-quote and automatically have the closing single-quote changed as well?
I mean, I could do a selection on the first single-quote then Ctrl+Shift+L, which will show multiple cursors that will allow me to do it, but it does it for all the single-quotes. I only want it done on a single string or that one line only.
Is there a shortcut for this? (something like editor.linkedEditing setting)
Select the first quote, then Ctrl+D
Thanks to #rioV8!
Related
In a snake_cased language, I would want to navigate variablewise and not word_wise and also exclude sigils like #, % or / from these stops.
Example:
|$here_she_goes_again; #the pipe marks my cursor position
With one Ctrl+Right, I want to land on the space before the semicolon,
$here_she_goes_again|; #the pipe marks my cursor position
then, with a Ctrl+Left, I want to return to the beginning of the line.
|$here_she_goes_again; #the pipe marks my cursor position
Somebody got this to work?
Put this into your settings.json:
"[javascript]": {
"editor.wordSeparators": "`~!##%^&*()-=+[{]}\|;:'",.<>/?"
}
Use whatever your language identifier is. I deleted the $ from the default separators to get your example to work for javascript. You can remove the other characters you indicated. The underscore was already not in the default for me. Just make sure those characters are not in the language-specific setting shown above.
You can use the extension Select By and the command moveby.regex
You are able to define a regex to search and bind this to Ctrl+Left and another to Ctrl+Right
In the key binding you can limit this to a particular languageID.
Essentially I want the quotes to be switched according to the quote I press.
video - https://www.dropbox.com/s/72fb9zjctdmt0je/pycharm64_M2v48MSK78.mp4?dl=0
What you see in the video is me selecting quotes and then pressing other ones, for example 'test' if I select this with the single quotes and press " I expect it to turn into those quotes but if I select only the text it should just wrap another set of quotes around it.
this video was taken from PyCahrm.
So my question is:
Is there an extension out there that does this?
Can I do it with a keybind/settings?
If I have some items that were variable names that should actually be strings, is there a quick way to quote them once I select them, or do I need to manually type in the quotes on each side of the string?
If you highlight a word, pressing a quote key such as " will quote the word, instead of replacing the word with a quote.
I'd like to add a suffix to all occurrences of a variable in a file (eg. pluralizing a variable number --> numbers).
VSCode offers a multiselect option thru the default "cmd+d", or editor.action.addSelectionToNextFindMatch. However, after I do this over all occurrences of number, the entire variable is selected. I really just need the cursor to be at the very end, so I can add an s. I would like not have to retype numbers.
How can I achieve this?
As an alternative, I use a regex:
\b(var1|var2|var3)\b
And I replace it with the same content $1 (since I capture the variable name in a group with ()) followed by 's': $1s
I would just copy the variable first. So:
Double-click your variable and Ctrl-C
Ctrl-F2 selects all occurences
Ctrl-V and add your 's'
The regex method is better if you have a few variables to change, but not if you have only one or two to change. Really simple to create a macro if you would be doing this a lot - you could get it down to a single keychord.
[This unfortunately selects occurrences of var1 and someOtherVar1 (the Var1 part) - so if this is a problem better to use a regex as it is easier to exclude instances of the var1 term appearing within another word, like someVar1 that you do not intend to change.]
I'm using VIM do alot of work for me using the macros.
There's alot of text in columns and I want the macro to move between columns effortlessly by pressing the w key to "move to the beginning of the next word"
For example:
DataSourceName string ""
DetailFields []string
DynamicControlBorder boolean empty may be void
EscapeProcessing boolean True
FetchDirection long 1000
FetchSize long 12
Filter string ""
GroupBy string ""
HavingClause string ""
However when I do this, VIM only does this for letters; whenever it encounters a "[" or a " it interprets this as another word, messing up the macro because it now appears that there is an additional column.
Is there any setting I can change to make vim ignore the special characters and treat them just like the letters by skipping over them?
[Update]
I found an even better answer to this question over at superuser.com:
https://superuser.com/questions/12679/is-there-anyway-to-have-vim-not-count-special-characters-as-words/12828#12828
You could make the special characters a part of word, see the iskeyword option. In your case you could simply try the following commands:
:set iskeyword+=[
:set iskeyword+=]
The W command (Shift+W) moves to the next word delimited only by spaces, not whatever Vim is configured to consider a "word" (as unshifted w does).