Comments (4)
I'm using the following in my init.lua for lazy line selection:
function selectLineUp(bp)
if not bp.Cursor:HasSelection() then
bp:EndOfLine()
bp:SelectToStartOfLine()
else
bp:SelectUp()
bp:SelectToStartOfLine()
end
end
function selectLineDown(bp)
if not bp.Cursor:HasSelection() then
bp:StartOfLine()
bp:SelectDown()
else
bp:SelectDown()
end
end
I have Ctrl-Shift-Up
and Ctrl-Shift-Down
bound to these functions:
"CtrlShiftDown": "lua:initlua.selectLineDown",
"CtrlShiftUp": "lua:initlua.selectLineUp",
So in particular you could use these to quickly select a few whole lines via Ctrl-Shift-Up
or Ctrl-Shift-Down
(i.e. in whatever direction you like) and then duplicate them via Ctrl-D
.
from micro.
Hi,
Many thanks for sharing your functions - taking this as inspiration - and combining with #2583, I have written a SelectBlock
function:
function editor_SelectBlock(Current)
-- Extend the selection to include the whole of any line selected
if editor.HasSelection(Current) then
if Current.Cursor.CurSelection[1]:LessThan(-Current.Cursor.CurSelection[2]) then
-- forward -> backward
-- Extend selection to end
Current:SelectToEndOfLine()
-- Get EOL Character
Current:SelectRight()
-- Swap to end of selection
editor_SwapAnchor(Current)
-- Extend selection to begining of line
Current:SelectToStartOfLine()
else
-- backward -> forward
-- Extend selection to begining of line
Current:SelectToStartOfLine()
-- Swap to end of selection
editor_SwapAnchor(Current)
-- Extend selection to end
Current:SelectToEndOfLine()
-- Get EOL Character
Current:SelectRight()
end
else
Current.Cursor:SelectLine()
end
return true
end
This can be called before duplicateline
to achieve block duplication:
"CtrlD": "lua:initlua.editor_GetBlock, duplicateline"
Unfortunately these manipulations change the current selection (so you can't make multiple copies).
I will leave this open as I still feel duplicateline
is an irregular command and better solution should be found.
Kind Regards Gavin Holt
from micro.
I guess we can close this now as there is a work-around.
Kind Regards Gavin Holt
from micro.
Hi,
After downloading the new binary today, my selectblock
function no longer works. I suspect this is a result of Fix Deselect() after mouse selection 3f810c2 or Fix cursor moving down when selection exist #3091
This function is only used to extend the selection before using the DuplicateLine
action, to cope with with partly selected lines and I have it bound to Ctrl+D
:
"CtrlD": "lua:initlua.selectblock,DuplicateLine,EndOfLine",
It fails only when the lazy selection if from the bottom upwards!
Generally Micro will act upon partly selected lines (top down or bottom up) for all the following :
- MoveLinesDown
- MoveLinesUp
- IndentSelection
- OutdentSelection
- lua:comment.comment
- Textfilter
- SpawnMultiCursorSelect
DuplicateLine
remains an outlier, and my work-around no longer works!
Not wanting to upset the current users of DuplicateLine
could we have a DuplicateLines
action which acts on all partly selected lines?
Kind Regards Gavin Holt
PS. Naming things is hard: given a free hand I would rename DuplicateLine
action to Duplicate
(a method to duplicate selection, or current line if no selection, without using the clipboard), and that would allow a more logical use for DuplicateLine
(duplicate all partly selected lines or current line if no selection, without using the clipboard).
from micro.
Related Issues (20)
- Nightly builds are not the current master branch 😭 HOT 2
- Not working command and comnand switch HOT 2
- Micro 2.0.13 (Windows only) crashes when selecting a directory with "open" HOT 1
- IsWhitespace from util package not working HOT 6
- Alt-Shift-Left or Alt-Shift-Right are not recognized desipte getting detected in raw HOT 2
- Disable micro auto formatting bindings.json when adding new bindings HOT 1
- Garbled contents when reloading file with DOS line endings HOT 8
- Inconsistent keybindings behavior for Alt Shift Combinations HOT 4
- file manager plugin .. go up not work HOT 2
- Feature Request: Editor Width/Margins HOT 2
- JumpToMatchingBrace inconsistent with adjacent unpaired braces e.g. )[ or }( or )( HOT 10
- disable error HOT 2
- Confusion over missing bindings
- Differing copy-paste mechanics between tmux and non-tmux HOT 1
- Calling clipboard.Write in lua crashes micro HOT 6
- 2.0.13 micro-2.0.13-linux-arm.tar.gz may have been tampered with HOT 11
- Micro panics when cd-ing to root
- How to toggle softwrap + wordwrap in editor, and how to make it a default setting? HOT 2
- Colors in Color Schems appear wrong. HOT 1
- DeleteLine does not delete selected lines HOT 5
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.