Nano, writing lines - nano

In Nano, when my text hits the end of the window, it starts a new line instead of continuing on the line I'm writing in. How can I change this?
Example:
This is a test, writing
next line
This is what I want:
This is a test, writing $next line

Add set nowrap to your .nanorc.

To disable line-wrapping permanently you can add set nowrap in your ~/.nanorc file.
To toggle between line-wrap / no-wrap in a file you can use the shortcut Alt, then $ (Shift + 4).
To open a file with line-wrapping disabled use -w or --nowrap (e.g. nano -w filename).

Related

Atom IDE - Keybinding

I have disabled the default Atom IDE keybinding for the combination alt + f (In my keymap.cson):
'atom-text-editor':
'alt-f': 'unset!'
How to make it to show [ character when I click alt + f?
Here's how to do this, based on this forum entry:
Open the editor's init.coffee script file (Menu: Atom > Init Script...)
Insert the following text (make sure to use the right indentation:
atom.commands.add 'atom-text-editor',
'custom:insert-bracket': ->
atom.workspace.getActiveTextEditor()?.insertText('[')
Save the file.
Open the keybinding file (Menu: Atom > Keymap...)
Add the following mapping (replacing yours) to call the new command:
'atom-text-editor':
'alt-f': 'custom:insert-bracket'
Save the file.
As a last step, restart Atom.
This worked for me, pressing Alt+f now inserts an opening bracket (which is automatically completed with a closing bracket by Atom).

How to auto-indent code in the Atom editor?

How do you auto-indent your code in the Atom editor? In other editors you can usually select some code and auto-indent it.
Is there a keyboard shortcut as well?
I found the option in the menu, under Edit > Lines > Auto Indent. It doesn't seem to have a default keymap bound.
You could try to add a key mapping (Atom > Open Your Keymap [on Windows: File > Settings > Keybindings > "your keymap file"]) like this one:
'atom-text-editor':
'cmd-alt-l': 'editor:auto-indent'
It worked for me :)
For Windows:
'atom-text-editor':
'ctrl-alt-l': 'editor:auto-indent'
The accepted answer works, but you have to do a "Select All" first -- every time -- and I'm way too lazy for that.
And it turns out, it's not super trivial -- I figured I'd post this here in an attempt to save like-minded individuals the 30 minutes it takes to track all this down. -- Also note: this approach restores the original selection when it's done (and it happens so fast, you don't even notice the selection was ever changed).
1.) First, add a custom command to your init script (File->Open Your Init Script, then paste this at the bottom):
atom.commands.add 'atom-text-editor', 'custom:reformat', ->
editor = atom.workspace.getActiveTextEditor();
oldRanges = editor.getSelectedBufferRanges();
editor.selectAll();
atom.commands.dispatch(atom.views.getView(editor), 'editor:auto-indent')
editor.setSelectedBufferRanges(oldRanges);
2.) Bind "custom:reformat" to a key (File->Open Your Keymap, then paste this at the bottom):
'atom-text-editor':
'ctrl-alt-d': 'custom:reformat'
3.) Restart Atom (the init.coffee script only runs when atom is first launched).
Package auto-indent exists to apply auto-indent to entire file with this shortcuts :
ctrl+shift+i
or
cmd+shift+i
Package url : https://atom.io/packages/auto-indent
I prefer using atom-beautify, CTRL+ALT+B (in linux, may be in windows also) handles better al kind of formats and it is also customizable per file format.
more details here: https://atom.io/packages/atom-beautify
You can just quickly open up the command palette and do it there
Cmd + Shift + p and search for Editor: Auto Indent:
This works for me:
'atom-workspace atom-text-editor':
'ctrl-alt-a': 'editor:auto-indent'
You have to select all with ctrl-a first.
This is the best help that I found:
https://atom.io/packages/atom-beautify
This package can be installed in Atom and then CTRL+ALT+B solve the problem.
On Linux
(tested in Ununtu KDE)
There is the option in the menu, under Edit > Lines > Auto Indent or press Cmd + Shift + p, search for Editor: Auto Indent by entering just "ai"
Note: In KDE ctrl-alt-l is already globally set for "lock screen" so better use ctrl-alt-i instead.
You can add a key mapping in Atom:
Cmd + Shift + p, search for "Settings View: Show Keybindings"
click on "your keymap file"
Add a section there like this one:
'atom-text-editor':
'ctrl-alt-i': 'editor:auto-indent'
If the indention is not working, it can be a reason, that the file-ending is not recognized by Atom. Add the support for your language then, for example for "Lua" install the package "language-lua".
If a File is not recognized for your language:
open the ~/.atom/config.cson file (by CTRL+SHIFT+p: type ``open config'')
add/edit a customFileTypes section under core for example like the following:
core:
customFileTypes:
"source.lua": [
"conf"
]
"text.html.php": [
"thtml"
]
(You find the languages scope names ("source.lua", "text.html.php"...) in the language package settings see here)
If you have troubles with hotkeys, try to open Key Binding Resolver Window with Cmd + .. It will show you keys you're pressing in the realtime.
For example, Cmd + Shift + ' is actually Cmd + "
You could also try to add a key mapping witch auto select all the code in file and indent it:
'atom-text-editor':
'ctrl-alt-l': 'auto-indent:apply'
I was working on some groovy code, which doesn't auto-format on save. What I did was right-click on the code pane, then chose ESLint Fix. That fixed my indents.
If you are used to the Eclipse IDE or the Netbeans, you can use the package eclipse-keybindings (https://atom.io/packages/eclipse-keybindings):
This Atom package provides Eclipse IDE key mappings for Atom. Currently, the Eclipse shortcuts are directly mapped to existing Atom commands.
To format all lines from a file, just use: Ctrl+Shift+F.
Ctrl+Shift+i worked for me in PHP under Windows ... but some files did not react. Not being the brightest it took me a while to work out that it was the include files that were the problem. If you are using echo(' ... PHP ...') then the PHP does not get re-formatted. To get over this, create a temporary PHP file, say t.php, copy the PHP part into that, reindent it (Ctrl+Shift+i ... did I mention that?) and then copy the newly reformatted PHP back into the original file. Whilst this is a pain, it does give you correctly formatted PHP.

Create a file with content through ssh without a text editor

I am aware that it is possible to create a file in ssh through the "touch" command then editing it using text editors such as vi or pico to edit them and add content.
I was wondering if it was possible to create a file and add it's contents in one command line?
Something like:
[create file command] [filename.txt] ["this is the contents of filename.txt"]
The reason I'm asking if this was possible is because I have an ssh client in Go where a session only accepts one call to run and I plan to use this for an app that is automated with no user inputs so I want to avoid using text editors.
Here's one solution:
ssh [user#]hostname 'echo "this is the contents of filename.txt" > <path/filename>'
The echo with ">" overwrites an existing file, or creates a new file if it doesn't exist.
Replace ">" with ">>" to append the text to an existing file.
Cheers

how do you make Scite interactive?

Once I compile with Scite, my command prompt won't show up.
How do I set it up so I can accept inputs and outputs from the command prompt from my program using Scite?
In scite properties file Edit as below:
Change
command.go.*.c=$(FileName)
to
command.go.*.c=start $(FileName)
Pressing go opens the tatget file in new cmd window and is now interactable
Now you can give inputs
If you are using different language replace *.c with corrosponding one and put start before the command.

Copying the GNU screen scrollback buffer to a file (extended hardcopy)

How do I easily copy the GNU Screen scrollback buffer to a file? I.e., a more powerful version of the 'hardcopy' command?
In GNU screen, I can use "Ctrl + A Esc" to enter the scrollback
buffer. I could then mark the entire buffer and use "Ctrl + A Ctrl + ]" to paste it into an Emacs buffer, thus saving it to a file.
However, this is tedious. Is there a Screen command that'll simply copy the scrollback buffer to a file, like 'hardcopy' does for the visible portion of the screen?
To write the entire contents of the scrollback buffer to a file, type
Ctrl + A and :
to get to command mode, then
hardcopy -h <filename>
In older versions of screen, if you just do hardcopy -h, it just writes to the file -h. This was fixed in version 4.2.0, so hardcopy -h writes to hardcopy.N where N is the current window number.
Press Ctrl+A :bufferfile /tmp/somefile.txt ENTER, and then Ctrl+A >
This will write the current contents of the buffer to the named file.
TL;DR: ^A:writebuf <filename>
The OP seems to want a way to use the selected portion of the buffer you get when doing a ^A[ , selecting text using space as the start and finish, and then instead of using ^A] to paste, save the resulting selected portion of the buffer to a file.
This worked:
^A:writebuf <filename>
Note: one 'f' in writebuf
Try hardcopy -h to include the whole buffer.
This worked for me:
Enter edit mode (~) and type:
:hardcopy -h buff_file
It created a huge file, of which 98% was empty, but my logs were fully present in remaining 2%.
Ctrl + A, :, and issue the command 'log on'.
Or set it as the default in your .screenrc file as 'deflog on'.
Do Ctrl + A, H.
That saves the current screen into a hard copy file, e.g., hardcopy.0 for screen 0. It seems to be a quicker way than going Ctrl + A, : and typing the hardcopy command.