How do I specify “the word under the cursor” on VIM’s commandline?

Question :

How do I specify “the word under the cursor” on VIM’s commandline?,

Answer :

I want to write a command that specifies “the word under the cursor” in VIM. For instance, let’s say I have the cursor on a word and I make it appear twice. For instance, if the word is “abc” and I want “abcabc” then I could type:

:s/(abc)/11/  

But then I’d like to be able to move the cursor to “def” and use the same command to change it to “defdef”:

:s/(def)/11/  

How can I write the command in the commandline so that it does this?

:s/(*whatever is under the commandline*)/11  

,

While in command-line mode, CTRL+R CTRL+W will insert the word under the cursor.

Read More  How can I convert IEnumerable to List in C#? June 10, 2022 by Eiji I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView (WebForms). Simplified code: Dictionary dict = GetAllRecords(); myListView.DataSource = dict.Values.Where(rec => rec.Name == "foo"); myListView.DataBind(); I thought that would work but in fact it throws a System.InvalidOperationException : ListView with id ‘myListView’ must have a data source that either implements ICollection or can perform data source paging if AllowPaging is true. In order to get it working I have had to resort to the following: Dictionary dict = GetAllRecords(); List searchResults = new List(); var matches = dict.Values.Where(rec => rec.Name == "foo"); foreach (Record rec in matches) searchResults.Add(rec); myListView.DataSource = searchResults; myListView.DataBind(); Is there a small gotcha in the first example to make it work? (Wasn’t sure what to use as the question title for this one, feel free to edit to something more appropriate) Try this: var matches = dict.Values.Where(rec => rec.Name == "foo").ToList(); Be aware that that will essentially be creating a new list from the original Values collection, and so any changes to your dictionary won’t automatically be reflected in your bound control. Categories question Post navigation .NET unit testing packages Authenticating Domain Users with System.DirectoryServices

See the help for c_CTRL-R for a listing of all the other special registers:

:help c_CTRL-R  

That’s the answer How do I specify “the word under the cursor” on VIM’s commandline?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you

Read More  How to animate the command line?