Questions tagged [vi]

Vi is a screen-oriented text editor originally created for the Unix operating system.

Vi is a screen-oriented text editor originally created for the Unix operating system.

vi is a modal editor: it operates in either insert mode (where typed text becomes part of the document) or normal mode (where keystrokes are interpreted as commands that control the edit session). For example, typing i while in normal mode switches the editor to insert mode, but typing i again at this point places an "i" character in the document. From insert mode, pressing the escape switches the editor back to normal mode. A perceived advantage of vi's separation of text entry and command modes is that both text editing and command operations can be performed without requiring the removal of the user's hands from the home row. As non-modal editors usually have to reserve all keys with letters and symbols for the printing of characters, any special commands for actions other than adding text to the buffer must be assigned to keys which do not produce characters, such as function keys, or combinations of modifier keys such as Ctrl, and Alt with regular keys. Vi has the advantage that most ordinary keys are connected to some kind of command for positioning, altering text, searching and so forth, either singly or in key combinations. Many commands can be touch typed without the use of Shift,Ctrl or Alt. Other types of editors generally require the user to move their hands from the home row when touch typing:

  • To use a mouse to select text, commands, or menu items in a GUI editor.
  • To the arrow keys or editing functions (Home / End or Function Keys).
  • To invoke commands using modifier keys in conjunction with the standard typewriter keys.

For instance, replacing a word is cwreplacement textEscape which is a combination of two independent commands (change and word-motion) together with a transition into and out of insert mode. Text between the cursor position and the end of the word is overwritten by the replacement text. The operation can be repeated at some other location by typing ., the effect being that the word starting that location will be replaced with the same replacement text.

Source: wikipedia

38 questions
30
votes
7 answers

Why do I not have syntax highlighting when I sudo vi ?

I don't understand how to allow syntax highlighting in files I'm editing via vi when using sudo. When I sudo vi the terminal is only black & white of my terminal settings. In vi if I enter :syntax on nothing changes. When I vi
Scott Lundgren
  • 411
  • 1
  • 5
  • 7
13
votes
4 answers

Save file after forgetting to open as root / sudo vi

Possible Duplicate: vim re-edit as root I could have sworn I saw this question asked. But after looking though every search result for "vi" I'm stumped/lazy. I've opened a file, made an edit and now I realize it's read only and I've opened it as…
MathewC
  • 6,877
  • 9
  • 38
  • 53
11
votes
4 answers

How to save + close file when editing in bash?

OK - I am linux newbie - I am trying to edit a file from bash via edit command in whatever the default mode is (I am assuming 'vi'?). Problem is for the hell of me I cannot how to save and out of edit mode - this cheatsheet seems to…
JohnIdol
  • 435
  • 3
  • 10
  • 18
10
votes
5 answers

How to enable color in Vim over SSH?

I have two remote servers: Server 1: Linux 2.6.18-238.12.1.el5PAE i686 / VIM - Vi IMproved - version 7.0.237 Server 2: Linux 2.6.18-338.19.1.el5.lve0.8.36 x86_64 / VIM - Vi IMproved version 7.0.237 When I ssh into Server 2 and use vim to edit a php…
cwd
  • 2,693
  • 9
  • 32
  • 47
10
votes
3 answers

Can I log vi activity?

Is there any method to log vi activities? I suspect that another user is issuing commands by going into the shell inside the vi editor, apparently those command doesn't record into history.
vnix27
  • 856
  • 2
  • 11
  • 19
10
votes
4 answers

Change default crontab editor to nano in FreeBSD

When I edit the crontab using crontab -e it opens the crontab in vi. I'd prefer it to use nano. How can I change this? EDIT: For some reason the export command returns command not found. And changing the EDITOR env value didn't work for crontab…
Ian
  • 1,488
  • 4
  • 26
  • 32
7
votes
1 answer

Linux: Lost internet while using vipw. How can I unlock the file?

I was editing the passwd file with vipw, when I briefly lost internet connectivity. When I logged back in and tried to edit again I get the error: vipw: Couldn't lock file: Interrupted system call vipw: /etc/passwd is unchanged I'm assuming this…
LoneWolfPR
  • 275
  • 1
  • 3
  • 17
7
votes
7 answers

How can I open a file with line numbers displayed from the command line in 'vi'?

I've seen so many examples/usages about how to display/hide line numbers in vi edit mode. To turn on line numbers: Type :set number in edit mode To turn off line numbers: Type :set nonumber in edit mode I wonder whether there is any convenient…
Gnanam
  • 1,439
  • 13
  • 26
  • 32
6
votes
3 answers

bad interpreter: Text file busy

For ages I've gotten used to editing Perl CGI scripts in "vi" and simultaneously having a browser open to test them. Lately, I've been getting "500" server errors when I do that, and when I run the script from the shell, I get "bad interpreter:…
JoelFan
  • 2,165
  • 5
  • 24
  • 30
4
votes
7 answers

how do I use the # key in vi?

How can I make a number sign show up???
thanksyo
  • 839
  • 2
  • 8
  • 8
4
votes
2 answers

best ways allowing a group to edit some /etc files

we have a group called JBossAdmins and users of this group must edit some /etc files on a RHEL 6: /etc/httpd/* /etc/java/* /etc/jboss/* my first idea was to give the following sudo permissions: %JBossAdmins ALL=(root) /bin/vi…
JMW
  • 1,451
  • 4
  • 19
  • 27
3
votes
1 answer

Can vim execute buffer without addons?

If editing some script in vim, a file with .py or .sh extension, is it any build-in vim command that allows to run such file? I know it's a lot of IDE-like addons for VIM that allows to execute files vim edit, but is it possible without addons?
grigoryvp
  • 3,415
  • 11
  • 38
  • 58
3
votes
1 answer

Command output in vi editor

I open a text file using vi editor in linux and want to insert date command output without exiting vi editor. What is the trick? Thanks
vnix27
  • 856
  • 2
  • 11
  • 19
3
votes
4 answers

How to use cursor keys in vi under screen?

If you run vi/vim in screen, when you press a cursor in insert mode, you get a new line + a character, which is a pain. How can I configure vim to move around instead?
Tim Abell
  • 1,311
  • 3
  • 10
  • 21
2
votes
3 answers

Disable VIM Syntax Highlighting

I am a system administrator and not a programmer. I frequently su to different system users for task so a .vimrc file for each system user is cumbersome. I need to be able to read the comments in config files and VIM syntax highlighting gets in…
JohnA
  • 556
  • 3
  • 12
1
2 3