View Single Post
Posts: 2,802 | Thanked: 4,491 times | Joined on Nov 2007
#2
Originally Posted by taimishu23 View Post
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.

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.

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.

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.
 

The Following 5 Users Say Thank You to lma For This Useful Post: