How can I create a new file with a simple way in spacemacs? - spacemacs

Currently, I know that I can create a new file with the following ways:
c key in Neotree
SPC ' in shell layer, and use the touch xxx command
I am wondering whether there is a simple way (something like SPC f xxx) or not.
Thanks.

Yes, you can use SPC f f, enter the name of the new file and then select the line starting with [?] (which is the default if no other file matches).
Note you can also use this to create files in non-existing subfolders, like SPC f f my/sub/folder/file.txt RET.

If you are using the standard vim like keybindings,
:e /path/to/file
works opens a file ( which doesn't have to exist before )
:x
saves the file and closes the buffer and
:w
saves without closing.

Related

is there a way to use the full file path in the command line without typing it?

For example, I want to open a PDF file in the browser from the command line (just because it's much faster and I need to open many files at once) and when I use the command start [file name] from its directory it try to open it as a executable, so I need to open the browser and type the full path of the file as an attribute, is there a way to call the full path without typing it?
what I exactly need is I need the full path of a file to convert it to string (for example in the browser)
Using tab completions may help. For example, if your target file is named thisPDFisTotallyBananas.pdf and you have another file in the same folder named thisOtherPDFisNot.pdf, you could type thisP then TAB to complete the file name in the command prompt without needing to type the whole filename.

delete all lines starting by: INSERT INTO `mdl_logstore_standard_log` VALUES

I have a SQL text file on my Linux server, and I need to remove all lines starting by
INSERT INTO `mdl_logstore_standard_log`
Looks like a duplicate of this.
Following the "Better Solution" in the chosen answer there, you would likely want to consider using sed. This will delete the lines without needing to open the file.
For your specific case, you can run
sed '/^INSERT INTO `mdl_logstore_standard_log`/d' text_file.sql > new_text_file.sql
where you'd replace text_file.sql and new_text_file.sql with your current file and the file with lines deleted. You may also want to consider looking at the -i (or equivalent --in-place) option if you'd prefer to overwrite your previous file with the new one.
You can achieve it with vim. Open the file, type :g and then make sure you run the following:
:g/^INSERT INTO `mdl_logstore_standard_log`/d
Explanation:
- ^ is the start of the string, here means starts with
- d at the end means delete
- the pattern between the slashes is the pattern to find
If it looks good, hit :w to save your file.

How to do a project-wide find and replace in Spacemacs?

I'm trying to do a project-wide find/replace in Spacemacs. I tried this:
SPC s a p
Type the text I want to replace.
C-c C-e
At this point Spacemacs tells me text is read-only. What am I missing to be able to preform the edit operation?
Use SPC p R to use projectile-replace which runs interactive query-replace on all files in the project.

Copy Name File and Rename Another File with that Name

I don't know anything about code or even to use CMD, but I would like to know how to rename a file with another's file name. Example:
I have a movie:
MOVIE.720p.2017.mkv
and a have a subtitle with the correct name
MOVIE 720p (2017).srt
what I want to do is copy the name from the .srt to the .mkv, without copying the extension.
but, I have a lot of movies with a lot of .srt, the command needs to know a rule to know which movies are which.
you can use TOTALCMD, very easy. Select the file and press Ctr+R (this task is make without copying the extension)
Just configure in TotalCmd this combination of task Ctr+R. Menu -> Configuration -> Misc -> Ctr + Win + R (from combobox) + Command (Select RenameOnly). Press APPLY

OpenVMS - Add STRING to Filename via DCL

I have a number of files created by a program on our selling system that are produced in a format like the following:
CRY_SKI_14_EDI.LIS
CRY_SUM_14_EDI.LIS
THO_SKI_14_EDI.LIS
THO_LAK_14_EDI.LIS
CRY_SKI_IE_14_EDI.LIS
These files differ in numbers depending on the split of our product to different brandings. Is it possible to rename them all so that they read like the following:
CRY_SKI_14_EDI_DEMO.LIS
CRY_SUM_14_EDI_DEMO.LIS
THO_SKI_14_EDI_DEMO.LIS
THO_LAK_14_EDI_DEMO.LIS
CRY_SKI_IE_14_EDI_DEMO.LIS
I need the files to be correctly named prior to their FTP as a hardcoded file could potentially not exist due to the brand not being on sale and terminate the FTP which would prevent the other files following it from being transmitted to our FTP server.
The OpenVMS rename command is more handy (imho) than the windows or unix variants, because it can bulk change chuncks of the full file name. Such as 'name', 'type' or (sub)directory.
For example:
$ rename *.dat *.old
That's great but it will not change within the chunks (components) like the name part requested here.
For that, the classic DCL approach is a quick loop, either parsing directory output (Yuck!) or using F$SEARCH. For example:
$loop:
$ file = f$search("*EDI.LIS")
$ if file .eqs. "" then exit
$ name = f$parse(file,,,"name","syntax_only") ! grab name component from full name
$ rename/log 'file' 'name'_demo ! rename 'fills in the blanks'
$ goto loop
Personally I use PERL one-liners for this kind of work.
(and I test with -le using 'print' instead of 'rename' first. :-)
$ perl -e "for (<*edi.lis>) { $old = $_; s/_edi/_edi_demo/; rename $old,$_}"
Enjoy!
Hein