So I just started using Neovim/Spacevim, and it's so awesome!
I am still getting used to everything, since I have never used Vim or anything like that before.
My question revolves around searching for particular text in all the files of the currently open project.
I am using the nerdtree file manager, and I was wondering how I might search through all the files in the project for a specific string. Like if I wanted to search function thisExactFunction() throughout the currently open folder/directory, how would I go about doing that? The main goal is to have a list of all the files that contain this search string.
I have fzf installed (as well as ripgrep), but seem to be having trouble in searching for specific text inside of all files. I can only search for files themselves, or some other search that does not yield what I need.
Can anyone point me in the right direction...? Thanks!
Check out the Ggrep command that Fzf supplies - see this series of vim screencasts to see how to use vim's in built features (quickfix list populated by :vimgrep) to achieve the same using other grepping tools.
Custom functions
I have a function in my .vimrc that uses ag silver
searcher to search within all
the files in a directory (and any subdirectories). So if you install ag, this
should work:
" Ag: Start ag in the specified directory e.g. :Ag ~/foo
function! s:ag_in(bang, ...)
if !isdirectory(a:1)
throw 'not a valid directory: ' .. a:1
endif
" Press `?' to enable preview window.
call fzf#vim#ag(join(a:000[1:], ' '),
\ fzf#vim#with_preview({'dir': a:1}, 'right:50%', '?'), a:bang)
endfunction
" Ag call a modified version of Ag where first arg is directory to search
command! -bang -nargs=+ -complete=dir Ag call s:ag_in(<bang>0, <f-args>)
Bonus
Sometimes it's hard to find things in vim's help, so I also have a function
that uses the one above to interactively search the help docs. This can be nice
to hone in on the topic you want. Use :H for this function (as opposed to the
classic :h)
function! Help_AG()
let orig_file = expand(#%)
let v1 = v:version[0]
let v2 = v:version[2]
" search in the help docs with ag-silver-search and fzf and open file
execute "normal! :Ag /usr/share/vim/vim".v1.v2."/doc/\<CR>"
" if we opened a help doc
if orig_file != expand(#%)
set nomodifiable
" for some reason not all the tags work unless I open the 'real' help
" so get whichever help was found and open it through Ag
let help_doc=expand("%:t")
" open and close that help doc - now the tags will work
execute "normal! :tab :help " help_doc "\<CR>:q\<CR>"
endif
endfunction
" get some help
command! H :call Help_AG()
Please excuse the stupid question, but I am an absolute freshman in Crystal Reports.
I would like to add a plaintext to Crystal Reports. The problem is, if a hyperlink has been inserted that contains a display text, it will be displayed as follows:
HYPERLINK "http://google.de/https://www.google.com/webhp?hl=de&sa=X&ved=0ahUKEwipsMvN_-vkAhWCEVAKHf3JBCIQPAgD " google.com
I just want the hyperlink to be displayed within "
The result should be https://www.google.com/webhp?hl=de&sa=X&ved=0ahUKEwipsMvN_-vkAhWCEVAKHf3JBCIQPAgD
However, it is also possible that "hyperlinks" that do not contain a hyperlink may occur.
My professor has created an Access database that contains texts and hyperlinks and I have to display the hyperlinks correctly.
Some lines of the database:
HYPERLINK "http://votetandem.org/" votetandem.org
HYPERLINK "https://app.votetandem.org/"votetandem.org
Sometimes there is a space between "URL" display text and sometimes not
Use the REPLACE() function. Hit F1 for online help.
I found a solution for my problem. I created a formular field. chr(34) is " in ASCII
If InStr({TABLE},"HYPERLINK " & chr(34)) > 0 Then
Split({TABLE},chr(34))[2]
else
{TABLE}
the URL is the second entry. The first is Hyperlink, second real URL and the third the displayed name.
I am having a word document which is containing many words like this. I have shown below.
(00:05), (01:18), (09:45), (21:42)
How do I remove these words with single expression using wildcards?
Any help would be greatly appreciated!! Thanks!!
In Search and Replace dialog, you have "More >>" and you will be able to see the "Use wildcards" option. After tick, you can search \(*:*\).
Before :
(00:05), (01:18), (09:45), (21:42)
After :
, , ,
Is there any way to find all Strings in my source code regardless of their content. In other words I want to find everything that starts and ends with " . What I want to do afterwards is replace all found strings with someMethod(string).
Edit:
I think I have not expressed myself clear. I want to find all strings no matter what the content between the " is and the "encapsulate" them. In your example syso("test") should become syso(somethod("test"))
You can use the Find In Project functionality using the Basic Wildcards options.
Then use the * wild card and search for syso(*) . This will return all occurrences of this method. Then manually you can replace the text you want.
CTRL+F - search for " and replace manually:
search for : the thing you want to replace(e.g. ")
replace with: the thing you want to past instead (e.g.someMethod())
-> But look out for errors! think about replacing bevor you try it- because if you replace all " with somemethod, you have a lot of errors! Look at this example:
syso("test");
//---replace actoin: someMethod() instead of "
syso(someMethod()testsomeMethod())
-> best way is to make this kind of manipulations (in my oppinion): manually!
Perhaps there are some Refactoring-Tools in Netbeans which could help you-but i don´t think that there is a "simple and easy" solution.
If you are searching for a solution for the whole project you are working on, go into the Edit menu-y there ou should find a item for "Replace in Project";
I hope i understood you right & could help a little!
I'm writing a simple Facebook status update web app that uses Graph API. It works well except for when I'd like to include a line break in the status message. I've tried adding a simple HTML tag, but this is just rendered as text.
Anyone know if this is possible, and if so, how?
It sounds silly, but this works:
Insert <center></center> where you would normally put <br>.
\r\n seems to work just fine to get line breaks in facebook
If you're using PHP or any language just add chr(10) and this will add a break :)
ASCII Solution :P
Please observe the new line that is used in the below code (an enter is hit inside the editor), that serves the purpose of adding new line to a post at a specific location:
$fb_status_with_new_line = "Text before new line" . "
" . "Text after new line";
If you replace return characters (\r) with new line characters (\n) you can achieve the desired result.
Enjoy...
%0A might work, i think i used that on one of my apps before.
HTML Decimal:
HTML Hexadecimal:
Java Hexadecimal: \u000A (Common To Javascript)
URL Hexadecimal: %0A
Escape Sequence: \n
HTML tag : <br>
Hope these come in handy :)
As of Dec 2013, this works (break lines in code):
$facebook->api('/me/feed', 'post', array('message'=> 'Line 1
Line 2
Line 3
Line 4',
'cb' => ''));
I've tried <center></center> it didn't work.
I've tried <br> it didn't work.
I've tried with invisible html characters, it didn't work.
I've tried with '\n' it didn't work.
However when I used "\n" instead of '\n' it worked. But this was recognized directly by the php before it was uploaded to facebook. So my suggestion is using double quotes with string messages in facebook posts.
If you are using PHP, you can do like this:
$message = str_replace('\r\n', "\n", $message); // input is from textarea
$ret_obj = $facebook->api('/me/photos', 'POST', array(
'source' => '#' . $photo['file_source'],
'message' => $message)
);
Please use double quote "\n" instead '\n'
\n Worked Its smallest an easiest way to add line breaks
You need to add carriage return i.e \n\r because facebook accept only enter for new line.
\n works. You just need to add it to the message param
\n working I checked now on twitter.
$post = $connection->post('statuses/update', array('status' => "first line \n second line"));
Just do it like so, It will work for other social media also
I use the messenger API with PHP.
For me, the string '\n' is working.
Beware that this is not the newline character (aka "\n").
No, it's '\' followed by 'n', aka "plain antislash-N".
if You are using iOS mobile platform the \n will supports fine.. message = encodeURIComponent(message) .. bur for android nothing is working for me searching for me..
None of the solutions offered worked for me when trying to post a comment on Facebook using Chrome. The only solution I have found is to highlight text that has a linefeed, then paste in that text, then erase all of the paste except the linefeed.
In my case (in bash) newline works only with newline character $'\n', e.g.
echo "Message text"$'\n'"#kw"