Entering italics in vim - vim

How does one enter italic text in vim?
In the following screenshot from the infopage of a certain plugin
you can see the italic text under the heading Text styles.
It is not my goal to highlight comments in italics as has been asked in many other questions.
I am looking for a keymap by which I can toggle to "italic text mode" and back.

You can't "enter italics", or bold, or underlined. Neither in Vim nor in any other text editor. What you insert is plain characters which get displayed according to their context.
What you see in that screenshot is the effect of a special rule defined in the plugin that tells Vim to italicize text between underscores and "conceal" those underscores. That feature is plugin-specific and can be enabled/disabled with an option.

You can always save your text file in .md format and use markdown syntax for italics.
For example:
In terminal insert vim text_file_name.md to open new text file in vim.
Then in this text file insert some text surrounded with asterixes eg. Some text in * italics *.
It should automatically show word "italics" in italics.

Vanilla VIM doesn't support this. It's just a text editor. You would need to use a plugin like Txtfmt.

Related

Use visual character-wise selection as auto-fill for Vim substitute command

Imagine that [ ] represents a selection. So given
This is pi with the 10th through 20th digits obscured: 3.14159265[3589793238]46264338327950288419716939937510...
the visual selection would be 3589793238.
In Sublime Text, when you have some text selected, and then press Ctrl+h to start the search/replace feature, it will auto-fill the search box with the currently selected text. Is there a way to emulate this in Vim? That is, assuming I am in character-wise visual mode and have made the selection indicated above, I would then press some shortcut combo and Vim would yield :%s/3589793238/ in the command line. That way I could simply complete it like so :%s/3589793238/___/ to replace 3589793238 with ___ throughout the currently open file (without having to manually type 3589793238 into the Vim command-line).
In command mode, you can input the content of any register with <C-R> followed by its name. So you could yank the currently selected text (yanked text is stored in register 0) and then input it with <C-R>0 when writing your substitute command.
To fully automate this, you could add a mapping like so:
xmap <leader>s y:%s/<C-R>0/

How can I easily edit after finding text in Sublime Text 3?

Whenever I do a sublime find, at some match I wish to add the text. But is there a shortcut to edit without moving mouse and clicking the text (to bring cursor to that location)
Example gif (issue I'm facing) - https://imgur.com/wTe3vcA
Just press Esc after finding your text.

Sublime Text 3 - highlight hyperlinks

I am completely new to Sublime text 3 and at the moment only want to use it to work with normal text files (no source code), containing a lot of URLs.
At first, I tried Sublime Text 2 which would be pretty good for what I want because with "plain text" syntax it automatically highlights links in red. For ST3 I tried for hours to get this to work, but for every syntax I tried there are some characters (like " and ') that screw up my document (e.g. highlight half of it because there is a single ' somewhere in it).
All I would like is a different color for URLs. How can I do this? And how can I set this to be the default, so that it stays that way when I restart ST3?

Background color, notepad++ for highlighting purposes

Is there a way in Notepad++ to highlight a snippet of text and change it's background color? I would like it to remain that color within the editor for highlighting purposes. I don't want the color to change the code at all.
You can get the effect you want by right-clicking on the highlighted snippet and selecting "Style token" -> "Using (n)th style".
This will also highlight any other sections of your code which are identical to the one you selected, which may or may not be what you want. However the highlighting will only remain for as long as you have that file open in notepad++. If you close it, you will lose the highlighting.
In Notepad++
First select the line/words to be highlighted
Go to 'Search' Menu
Select 'Mark All'.
There you will find 5 sub-menu as 'using [1..5]th style'.
(using 1st style : cyan colour) .
(2nd : light brown) .
(3rd : yellow) .
(4th : purple) .
(5th : green) .
However the highlighting will only remain for as long as you have that file open in notepad++. If you close it, you will lose the highlighting.
You can also define a language that set the snippet as a keyword and choose style for it.

Search for selection in Vim

I use Vim and Vim plugins for Visual Studio when writing C++. Often, I find myself wanting to search for a string within a function, for example every call to object->public_member.memberfunc().
I know Vim offers a convenient way to search for a single word, by pressing * and #, and it can also search for typed strings using the ubiquitous slash / command. When trying to search for all the instances of a longer string like the one above, it takes a while to re-type after /.
Is there a way to search for the selection? For example, highlight with v, then copy with y, is there a way to paste after /? Is there an easier shortcut?
Check this Vim tip: Search for visually selected text
Or you can simply yank the selected text with y and go to search mode /, then you can paste the last yanked text with Ctrl+R 0
Answer
Yank the text you want to search for
q/p
Enter
Explanation
q/ works similarly to vanilla search / except you're in command mode so p actually does "paste" instead of typing the character p. So the above will copy the text you're searching for and paste it into a search.
For more details type :help q/
Use q / instead of just /. (Same with q :). Now you can VIM-edit through your command and search history! (Try Ctrl-N and Ctrl-P sometime).
I just learned (through the excellent book Practical Vim) that there is a plugin for that.
You can find the plugin on GitHub.
The plugin lets you search for a visual selection with * and #.
You can actually select text visually and press * and # to search for the next occurrence... It will work the same, the only caveat is that:
Whitespace in the selection matches any whitespace, when searching (searching for "hello world" will also find "hello" at the end of a line, with "world" at the start of the next line).
http://vim.wikia.com/wiki/Search_for_visually_selected_text
--> if you want to highlight a text occurrences in gvim
Select the text & copy
then ?paste the selected text (Note: This will not work for insert mode)

Resources