I'm trying to figure out the easiest way to edit text files in the console (PowerShell in my case). I'm using Windows 7 64 bit. It galls me that I can't just type edit filename.txt
to edit a file. That used to work, but that's all changed. What are my options to view and edit text files within the windows console, and if you tell me to install and learn VIM I'm going to punch you in the face. :-)
相关问题
- How to change the first two uppercase characters o
- Installing Gemalto Developer Suite on Windows 7
- Looking for light text rich editor for enterprise
- Windows 7 Professional: Fails to install Visual C+
- Using Rstudio as an IDE for other programming lang
相关文章
- BHO for capturing user clicks works fine in Window
- Open Atom editor from git shell
- Ruby on Rails Win7 x64?
- Alternative to TextPad's Prompt to Reload File
- Why can't turn off the Sublime 3 updates notif
- x64 Application Accessing mdb database
- Failed to load aspnetcorev2.dll hosting ASP.NET Co
- Are there any good F# text editors?
You could install Far Manager (a great OFM, by the way) and call its editor like that:
I had to do some debugging on a Windows Nano docker image and needed to edit the content of a file, who would have guessed it was so difficult.
I used a combination of
Get-Content
andSet-Content
and base 64 encoding/decoding to update files. For instanceEditing foo.txt
The trick is piping the base 64 decoded string to
Set-Content
Its no vim but I can update files, for what its worth.
In linux i'm a fun of Nano, i'm always using nano, and is really a great choice. There is a version for windows. Here is the link https://nano-editor.org/dist/win32-support/
However more often we need to open the file in question, from the command line as quick as possible, to not loose time. We can use notepad.exe, we can use notepad++, and yea, we can use sublim text. I think there is no greater then a lightweight, Too powerful editor. Sublime text here. for the thing, we just don't want to get out of the command line, or we want to use the command line to be fast. and yea. We can use sublime text for that. it contain a command line that let you quickly open a file in sublime text. Also there is different options arguments you can make use of. Here how you do it.
First you need to know that there is subl.exe. a command line interface for sublim.
1-> first we create a batch file. the content is
We can save that wherever we want. I preferred to create a directory on sublime text installation directory. And saved there the batch file we come to write and create.
(Remark: change the path above fallowing your installation).
2-> we add that folder to the path system environment variable. and that's it.
or from system config (windows 7/8/10)
then:
then:
then we copy the path:
then we add that to the path variable:
too quick!
launch a new cmd and now you've got subl command working well!
to open a file you need just to use subl command as fellow:
you can also use one of the options arguments (type --help to see them as in the image above).
Also note that you can apply the same method with mostly any editor of your choice.
install vim from online, and then you can just do: vim "filename" to edit that file
I agree with Sven Plath. Nano is a great alternative. If you have Chocolatey setup. Install nano by typing the following in Powershell:
Then, to edit somefile.txt enter:
It's pretty neat!
Edit: Nano works well on my Windows 10 box but takes incredibly long to load the first time on my Windows 7 machine. That made me switch to vim (vi) on my Win 7 laptop
Add a line in the powershell profile to Set-Alias (sal)
Esc - : - x - Enter :-)
While risking you punching me, I guess you are stuck with the solution you mentioned. Have a look at this posting on SuperUser:
Which are the non-x text editors in Powershell?
Also, there is a nano version for windows:
Nano Editor
I'll duck and cover now, hopefully someone will have a more sufficient answer.