In a Notepad++ or an editor with similar features, is there an easy to search for a word which contains a number? For instance, suppose numbers were denoted by "~", then if I searched for "abc~" in the following text:
abc4
abc not a number
I would simply get the first word.
Use the "regular expression" search mode. If you just want to find groups of numbers, use \d+. If you want it to select the whole word containing one or more digits, use \w*\d+\w*.
Type this regular expression in the Find dialog box (select the regex option):
\w*\d\w*
Related
I have a text like this:
this is any text
Could sublime text convert it to?
this-is-any-text
insert hyphens between each space
In addition to the suggestions given in the comments, there is another option - the Case Conversion plugin. Edit → Convert Case contains Title Case, Upper Case, Lower Case, and Swap Case. Case Conversion provides:
snake_case
SCREAMING_SNAKE_CASE
camelCase
PascalCase
dot.case
dash-case
separate words
separate with forward slashes
separate with backslashes
To use it, simply highlight the section of text you want to convert and select the desired operation from the menu, or use the assigned keyboard shortcut, which will show up on the menu. You can combine this with Find by using a regex pattern to only select certain areas.
Note: While I have contributed to the Case Conversion repo (I added the backslash feature), I am not its author, just a very satisfied user.
I have done as indicated by #odatnurd in sublime text I have selected the first space, then the following with CTRL + D and finally when they have all been selected I put a hyphen - and they have all been converted to a hyphen
I would like to select a specific text on Sublime text, I looked for tutorials on how to do it but I can't find what I want.
As you can see on the screen, I'd like that from a word, for example "hello", it selects the sentence where there is the word but also the 2 sentences underneath.
Is it possible to do this?
in red represents the selection
I think you are using the word 'sentence' when what you mean is a 'line' and what you want to do is to construct a RegEx to select the line a specific word is on and also the contents of the next 2 lines.
If that is right then the following regex does what you want and seems like what is shown in the screenshot that you posted.
(hello)(.*\n){2}(.*)
My question is very simple:
Is there a shortcut in Sublime Text 3 which allows to remove blank lines in a selected text? (same for blanks in a line)
For instance, how to make this text:
a
b
c
To become:
a
b
c
And this line:
I need to remove these blanks.
to become this line:
Ineedtoremovetheseblanks.
You don't need a plugin to do this, a simple regex search and replace will do. First, select the text where you'd like to delete the blank lines. Then, select Find → Replace… (or, hit CtrlH on Windows/Linux, ⌘⌥F on OS X). Make sure the "Regular Expression" and "In selection" buttons are selected:
In Find What:, enter ^\n, and make sure the Replace With: field is empty. Then, simply hit "Replace All" and this:
becomes this:
As a bit of explanation, the regular expression ^\n searches for the beginning of a line (^) immediately followed by a newline character (\n). If you suspect that some of your "blank" lines contain whitespace, like space or tab characters, you can use ^\s*\n instead - \s* matches 0 or more whitespace characters, including newline characters.
For your second example, use the same Find/Replace settings as above, except your regular expression should simply be \s*.
There is a package called Trimmer. You can install it via Package control.
After you got the package you can use its functionalities. Just highlight the text you want to change (or don't select anything if you want to change the entire file) and then choose:
1) Edit > Line > Delete Empty Lines
2) Edit > Line > Remove Blank Spaces
Alternatively, as Chris's answer already pointed out you can use the classic search & replace functionality that is already present in the editor.
AS my original answer was incorrect, I have found this package which will be suitable for your needs.
The package is called DeleteBlankLines, for Sublime Text 3, has the ability to delete blank lines for the entire document and within the selected text only, all from a key stroke just like you were after.
The package can be found here:
https://packagecontrol.io/packages/DeleteBlankLines
I prefer using \s+, which will get one or more (i.e., the + character) whitespace characters (i.e., the \s escape sequence).
The * character will do zero or more, which on some versions can break up the individual words into letters.
Is it possible to search for a specific text in cells and move it?
For example: "ABCD [45] - City"
Result: "[45] ABCD - City"
Of course you can.
It is possible by code, formulae or search/replace (using regex).
In your example you search for something in square brackets and put this finding in front.
A regular expression search here will be
search for: (.*)(\[.*\] )(.*)
replace by: $2$1$3
Don't forget to tick the option "regular expression"
[Everything to search and replace with this is explained in online help: F1]
If you want code or formulae to have the task accomplished: ask more specific!
I am checking a log file using vim. There's only one word can be highlighted, when I search another word,the second word is highlighted but the previous one is not highlighted anymore.
Can anyone show me a way that easily highlight/cancel highlight multiple words in vim? For example, I want to highlight words "stack", "over" and "flow", then I want to cancel the highlight of "stack" and highlight another word "error". So that I can analyze the log more efficiently.
Thanks.
There are two simple ways to highlight multiple words in vim editor.
Go to search mode i.e. type '/' and then type \v followed by the words you want to search separated by '|' (pipe).
Ex: /\vword1|word2|word3
Go to search mode and type the words you want to search separated by '\|'.
Ex: /word1\|word2\|word3
Basically the first way puts you in the regular expression mode so that you do not need to put any extra back slashes before every pipe or other delimiters used for searching.
/\v\/folder|\/copy - search for \folder and \copy
and add to .vimrc set hlsearch
To have all words highlighted in the same color and be able to search and replace all of then, add them as alternatives to the search pattern, e.g. /foo\|bar. My SearchAlternatives plugin provides handy mappings to add and remove patterns.
If you want different colors for different matches, you need a highlight mechanism different from the built-in search. My Mark plugin is used by many people for that. (The plugin page has links to alternative plugins.)