Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open micro with the file and cursor on the last line #1082

Open
exebook opened this issue Apr 4, 2018 · 15 comments
Open

Open micro with the file and cursor on the last line #1082

exebook opened this issue Apr 4, 2018 · 15 comments

Comments

@exebook
Copy link

exebook commented Apr 4, 2018

I often need to add few lines to the file at the end, that would be handy to have a cli switch to open a file and automatically scroll down to the end and put cursor at the last character in the file as well. Is this already possible? Can this be a feature otherwise?

@ghost
Copy link

ghost commented Apr 4, 2018

Maybe
echo „some line“ >> someFile.txt
Already does the job?

@exebook
Copy link
Author

exebook commented Apr 4, 2018

well, yeah for some simple cases it will do, but Micro is an editor, and editin in an editor is a good thing, you can check if the added line aligns with the existing lines, you can add more than one lines, the syntax will be highlighted, tabs and indents will work in a right way, you can copy/paste, etc..

@zyedidia
Copy link
Owner

zyedidia commented Apr 4, 2018

This is a bit hacky but at the moment you can do micro file.txt:10000 and as long as your file is less than 10000 lines it will put your cursor on the last line. It would probably be pretty easy to implement something like micro file.txt:end.

@ghost
Copy link

ghost commented Apr 4, 2018

maybe file.txt:-1 could be added as an unobtrusive option

@vikramdurai
Copy link

or how about micro file.txt --last-line

@ghost
Copy link

ghost commented Apr 5, 2018

Now what if you want to get the line before that? Maybe use Peano Numbers https://wiki.haskell.org/Peano_numbers

file.txt —pre(pre(last-line)) to get to the line before the line before the last line :D

@vikramdurai
Copy link

can we make it a command?

@vikramdurai
Copy link

"C-e last"
which will put you on the last line.
"C-e last 6". which will put you on the line 6 lines before the last line.
I think this will work!

@ghost
Copy link

ghost commented Apr 5, 2018

"C-e last"
which will put you on the last line.
"C-e last 6". which will put you on the line 6 lines before the last line.
I think this will work!

Ctrl+L works for jumping to a line, it could support -1 as well to jump to lines, counting from the bottom

@vikramdurai
Copy link

I still think this needs to be a command though.
"C-e l i 4": the "l" is an abbreviation for the last line, the "i" means invert the ordering, and the "4" means the 4th line. But since "i" inverts the order, "4" becomes "-4" which is the 4th line before the last line.

@mixmastamyk
Copy link

Default keybindings are Ctrl+Down to end of file, I believe.

@jpmvferreira
Copy link

I would also like to support this feature and considering there's a goto command it shouldn't be too complicated to add a syntax like the one mentioned before micro file -1:1 to go to the last line, first column.

Personally I use micro to get the output of my terminal so I can easily copy output from terminal programs and obviously needs to start at the end, currently as a workaround I just set the starting line to be the maximum length of my terminal history, which also works as expected.

@terokarvinen
Copy link

Many text editors, including micro and nano, support

$ micro +9999999 foo.txt

It's also quite fast to type. I find it more obvious and universal than a special feature. If I would meet a file with more lines than strconv.Atoi can handle, I probably would not use a text editor to view it.

@Justinzobel
Copy link

Ctrl + Page Down seems to do nothing at the moment. This could be a shortcut to run goto -1 and would easily allow users to get to the bottom of a file.

@Justinzobel
Copy link

Did a bit of digging and added the custom commands to my bindings.json file:

    "CtrlPageDown": "command:goto -1",
    "CtrlPageUp": "command:goto 1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants