maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Newbie (https://talk.maemo.org/forumdisplay.php?f=26)
-   -   how to use VI xterm editor (https://talk.maemo.org/showthread.php?t=22038)

taimishu23 2008-07-18 03:53

how to use VI xterm editor
 
Since I'm too lazy to learn VI properly, can someone tell me how to enter the following commands?

edit/open a readonly document, for example a repository list file

delete text in a file (sorry, I'm stupid ;p)

save changes made to a readonly file

Of course once I start editing a readonly file it would mean converting the file to read/write...

All in all, probably not hard to do but I'm still learning the ropes. Thanks in advance.

lma 2008-07-18 07:18

Re: how to use VI xterm editor
 
Quote:

Originally Posted by taimishu23 (Post 204300)
Since I'm too lazy to learn VI properly

In that case you'd probably be better off installing nano from the diablo tools repository. If on the other hand you change your mind, you'll probably want to install vim from the same place, since the built-in vi is quite limited.

Quote:

edit/open a readonly document, for example a repository list file
If it's a file that you have permission to modify just edit as normal and use a "!" in the write command (eg ":w!") to force overwrite. Otherwise you'll have to become root first.

Quote:

delete text in a file (sorry, I'm stupid ;p)
Several ways:
  • "x" deletes the character under the cursor
  • "X" deletes the character before the cursor
  • "D" deletes to the end of the line
  • "dd" deletes the current line
  • "d" followed by a movement command deletes from the current to the new cursor position, for example:
    • "dw" deletes the next word
    • "db" deletes the previous word
    • "d^" deletes to the beginning of the line
    • "d$" deletes to the end of the line

Also, in vi you can prefix most commands with numeric multipliers, so for example "12x" deletes the next 12 characters and "5dd" the next five lines.

Quote:

save changes made to a readonly file

Of course once I start editing a readonly file it would mean converting the file to read/write...
See above. Even when vi overwrites a read-only file the permissions are not altered. You should probably avoid changing permissions, especially to system files like the repository list.

allnameswereout 2008-07-18 12:26

Re: how to use VI xterm editor
 
You can also install VIm from Garage if you prefer.

Straightforward VI mini howto!

taimishu23 2008-07-18 12:56

Re: how to use VI xterm editor
 
Thank you kindly.

Yeah, the only reason I'm trying to edit a file I normally wouldn't touch is because the repository list has a bad dependency entry for one of the packages, which doesn't let me install the app.

zorg 2008-07-18 14:02

Re: how to use VI xterm editor
 
There are many right answers to questions like "how do I delete?"

No matter how lazy you are, in fact especially if you're lazy, you should look at a diagram of vi's "modes." You can see a good example at

http://www.ostc.de/vi-overview-eng.pdf

That is a six-slides-on-one-pdf-page intro to vi I just now found by googling vi modes. The second of the six slides is a diagram of vi's modes. I found plenty such diagrams by googling, but this was the best-looking. The other diagrams on that page are also really good.

The most confusing thing about vi for newbs is that it behaves differently depending on which mode it's in. You have to be able to go from one mode to another to be sure that any hint will work (or just say, "well, I *assumed* you'd be in edit mode!" and roll your eyes).

Most of the hints given in this thread assume you're in "command mode" in the above-mentioned diagram. Looking at the diagram, you can probably see that pressing the escape key puts you in this mode or does nothing if you're already in this mode. So if the hints behave unexpectedly, you may want to hit the escape key (the back button on my N800) first.

Jaffa 2008-07-18 14:28

Re: how to use VI xterm editor
 
FWIW, vim 7.0 is in Extras-devel.

I'll be promoting it to Extras when the launch script and menu item is integrated into the package: at the moment you have to open X Terminal before using it.

(It's one of the packages I'm using to test the re-invigorated mud-builder - in this case, directly from the upstream source tarball)

taimishu23 2008-07-18 21:36

Re: how to use VI xterm editor
 
yep, I'll be spending some time going thru those modes. In the meantime, its nano...


very off topic, but where in the file system are the folders that appear in the built-in file manager? I tried checking /home/user/mydocs and other logical folders but no dice.

Benson 2008-07-18 21:56

Re: how to use VI xterm editor
 
Nope, they're in MyDocs. They're hidden files (UNIXly, files starting with '.' are hidden) so that they don't show up in the file manager. Instead an entry is faked in, with a properly internationalized name, while the actual directories keep the same names.
Code:

ls -a /home/user/MyDocs/

cmdowns 2008-07-18 23:24

Re: how to use VI xterm editor
 
Maybe I'm doing it wrong, but the Xterm vi doesn't really seem that complicated for minor edits.

After launching "vi [file name]", I guess you start off in command mode. The D-pad moves the cursor, x deletes characters. Press "i" for insert mode where you can type whatever text you want to insert into the original file. Esc returns to command mode where you can use ":wq" to save and quit if you're confident that you did everything right, or ":q!" to quit without saving if you're afraid your messed something up.

I'm sure there's way more to it, but the above commands work for my minor modifications.

geneven 2008-07-18 23:38

Re: how to use VI xterm editor
 
That was a nice vi doc!

The trouble with vi or vim on a tablet, though Ii use it, is that the whole rationale is supposedly that it minimizes finger movement. That kinda falls apart when you are typing everything with one finger, which is what you are doing with a stylus.

taimishu23 2008-07-19 01:14

Re: how to use VI xterm editor
 
Thx for the hints cmdowns. I've tried a few of the commands the way you said and they work pretty well. I think I'll stick nano until I get used to VI/VIM, since it's a bit more newb-friendly for me :).

'Preciate you pointing that out to me Benson. EDITED OUT: I would guess that changing them from "." hidden directories to regular directories would be a bad thing? I was hoping for more integration between documents saved with Xournal and other apps and the more robust file manager. IS there a way to change these hidden directory names? (I tried "mv" and failed)

nvm, I found out that doing that does nothing other than add visible directories to the file manager with the same name and same contents. Weird that you have to be "root" in order to see/interact with those folders...

Cheers.

Benson 2008-07-19 01:25

Re: how to use VI xterm editor
 
It would break everything trying to access them automatically, or having a saved path in that place...

That said, if you want them handily accessible, one easy fix is to make links to them (probably outside the MyDocs tree; inside would work, but would give doubled links.):
Code:

cd
ln -s MyDocs/.documents Documents
ln -s MyDocs/.sounds Sounds

And so on, for the others.

It's also possible to place the directories elsewhere, and replace the .foo directories with links, but that makes things complicated for no real gain.

HondaCivet 2008-07-20 21:04

Re: how to use VI xterm editor
 
I am running Diablo and I can't seem to figure out how to install Nano. It doesn't show up in the Installable Apps directory and I'm not experienced enough to know what to do if it doesn't have a green arrow on Maemo that lets me download and install it, haha. Could anyone help?

vvaz 2008-07-20 22:35

Re: how to use VI xterm editor
 
Quote:

Originally Posted by geneven (Post 204650)
That was a nice vi doc!

The trouble with vi or vim on a tablet, though Ii use it, is that the whole rationale is supposedly that it minimizes finger movement. That kinda falls apart when you are typing everything with one finger, which is what you are doing with a stylus.

The other rationale for vi(m) using is minimizing of key input. And it works wonderful for tablets.

taimishu23 2008-07-21 00:52

Re: how to use VI xterm editor
 
To HondaCivet:

I installed my version of nano from here http://maemo.org/downloads/product/OS2007/nano/

another place is nitapps.com, there's a link to the file at the bottom of the page.

Hope that helps.

bizshop 2008-09-08 15:24

Re: how to use VI xterm editor
 
I'm using vim on n810/Diablo - only problem I have is there is no bottom status bar that shows up

vi shows filename line/total lines percentage(not sure of what)
vim shows nothing.

I'm sure there must be an option to turn the status message line on?
Hopefully to have it on all the time?


All times are GMT. The time now is 15:06.

vBulletin® Version 3.8.8