Comments (8)
That is how Cut
(Ctrl-x) already works: if there is a selection, it deletes the selection, otherwise it deletes the current line, like DeleteLine
does.
BTW I don't quite like the way how it is implemented. The Cut
action internally checks if there is a selection and either deletes the selection or the current line. I think it would be better if it only deleted the selection and Ctrl-x
was bound by default not to Cut
but to Cut|CutLine
(so that if the user doesn't want Ctrl-x
to delete the current line if there is no selection, the user can disable this behavior by binding Ctrl-x
to Cut
instead of Cut|CutLine
).
from micro.
I think what you are saying is similar but a different issue, possibly an incorrect behavior from Cut
. If Cut
does what you described ( I haven't checked the code yet ), we can probably just remove the non selection logic and default ctrl-x
to Cut|CutLine
. That's in fact my current bindings funny enough.
But anyway, that's another issue as I said (which could potentially be changed together).
What I was saying is that DeleteLine
function (or even CutLine
, CopyLine
) should respect selections and delete the lines where and when there's a selection. This is how it works on other editors and I am still struggling to get used to it 😅
I can probably raise a PR for this (and also the issue you mentioned) but that will be after I sorted out the other PRs I have since I am already spending quite a bit of time on other PRs.
from micro.
My point is that if we do what you suggest, i.e. make DeleteLine
respect selections, then Ctrl-k
will do the same thing as Ctrl-x
, so then the question is why do we need Ctrl-k
(and DeleteLine
) at all.
Ah, I've just realized that DeleteLine
is not the same thing as CutLine
, since it doesn't copy the line to the clipboard. (I'm too used to using Ctrl-x
for deleting lines, even when I don't need to copy them.)
So, yeah, it makes sense to make DeleteLine
respect selections (like DuplicateLine
does).
Question: if the selection does not fully cover its first and/or last line, should DeleteLine
delete just the selection itself, or the rest of its first and last lines too? Which behavior is more useful?
From a pure aesthetics/consistency perspective it seems better if it will delete just the selection: 1. DuplicateLine
also duplicates just the selection. 2. I've checked that in nano Ctrl-k
also deletes just the selection (haven't checked other editors though).
from micro.
I understand it is good to have consistency but if DeleteLine
just deletes the selection, then it is doing the same job as Delete
, which I could have just used Delete
.
My personal opinion would be it should also delete the first line and last line since that is doing what it says, deleting lines.
However, that's just my own opinion. But I think it should at least reacts to selection(s), the action is up for debate and I don't mind other people joining to vote/provide opinions on what they want.
from micro.
Yeah, good point. Now it seems more useful to me if it deletes the whole first and last lines. (DuplicateLine
is a slightly different case.)
from micro.
Hi,
You can use Lua to achieve the required deletion. Bind the following to a keyboard shortcut of your choice:
"YourKey": "lua:initlua.delsel,SelectLine,Delete",
I keep all my Lua in one file init.lua
and the delsel function is very simple:
function delsel(Current)
-- This avoids deleting EOL when deleting partially selected lines
if Current.Cursor:HasSelection() then
Current.Cursor:DeleteSelection()
end
end
This will delete all partly selected lines, or the current line if no selection.
Kind Regards Gavin Holt
PS I am struggling to achieve similar for duplicate line as my solution is now broken - see #3110.
from micro.
You can use Lua to achieve the required deletion. Bind the following to a keyboard shortcut of your choice:
"YourKey": "lua:initlua.delsel,SelectLine,Delete",
This is a smart trick, but it doesn't always work correctly. If the last line of the selection contains the whole line, this will also wrongly remove the next line below the selection.
...I think the behavior of DeleteLine
should be fixed in micro anyway. The existing behavior is, among other things, confusing: DeleteLine
deletes just the "current line", but when there is a selection, the cursor is not displayed, so the user doesn't know what is the current line.
I'm gonna implement a fix, it should be trivial.
from micro.
Implemented #3335 which makes DeleteLine
respect selections, among other things.
from micro.
Related Issues (20)
- palettero plugin breaks `\u001b[` keybindings
- lock to provide warning when opening a file already opened in another instance of micro HOT 2
- set filetype sets the filetype for all opened tabs and not the current focused HOT 4
- Feature proposal: TUI drop-down menus HOT 2
- Enhanced multi-line editing
- Why doesn't Micro use Nano's syntax coloring? HOT 6
- [WSL] Font changed to Raster Fonts when opening Micro
- Changing default linter behaviour HOT 1
- how to input nano keybinds into micro? HOT 4
- Maybe redo should keep cursor where modification happens (not respecting pure line change in redoing)? HOT 6
- Micro places compiled Java programs into incorrect directory when auto-compiling HOT 2
- Running remote commands causes the editor to freeze up HOT 2
- Scroll with moving the scrollbar - a small idea for more convenience HOT 2
- Request (or just a general question) about .mo (modelica) syntax highlight support. HOT 1
- Weird tab bar behavior HOT 1
- Jumping to matching brace not as expected HOT 5
- editorconfig not applied HOT 2
- XHTML? HOT 3
- Distribution with DotSlash? HOT 1
- Match brace highlight is not working at all. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micro.