Questions tagged [vi]

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

Filter by
Sorted by
Tagged with
2 votes
1 answer
94 views

vi undo "n-th" previous change

What I've seen so far is that I can only revert to a previous state but not selectively undo, say, only a change which was done prior to the last two changes. Example, I'm editing a 50 line file and ...
11 votes
4 answers
144k views

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 <filename> command in whatever the default mode is (I am assuming 'vi'?). Problem is for the hell of me I cannot how to ...
8 votes
7 answers
18k views

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 ...
0 votes
1 answer
163 views

Always hung on Vi, vim, but not nano when using company VPN

I have a strange problem. IT changed the VPN to a newer Cisco device. After connecting to the VPN, I can ssh to one of our corporate server. I can ls, cd, cat, sudo. BUT if I tried any editing using ...
0 votes
1 answer
113 views

vi: write relative range of lines to a file

I need to be able to write a range of lines from a file to another file, I've found the :<start>,<end>w <new file> solution but what I need is to be able to search for a string and ...
0 votes
2 answers
38 views

Return/edit "slash" search string in vi(m)

I've tried searching the web but the phrases are too general or I didn't know what to search for. If I use /(some IP address) in vi I know I can simply enter / (Enter) again and find the next ...
1 vote
1 answer
549 views

Home and End keys not working in vi on Ubuntu 16.04

In Insert mode, when I press End I get an F where the cursor is and Insert mode is canceled. This works on one system and not another. I have checked what is installed (vim, vim-common, vim-runtime,...
10 votes
5 answers
23k views

How to enable color in Vim over SSH? [closed]

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 ...
4 votes
7 answers
29k views

how do I use the # key in vi? [closed]

How can I make a number sign show up???
10 votes
4 answers
25k views

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 ...
30 votes
7 answers
30k views

Why do I not have syntax highlighting when I sudo vi <filename>?

I don't understand how to allow syntax highlighting in files I'm editing via vi when using sudo. When I sudo vi <filename> the terminal is only black & white of my terminal settings. In vi ...
3 votes
4 answers
1k views

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?
2 votes
3 answers
1k views

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 ...
2 votes
2 answers
1k views

ctrl-v key on AIX

I'm new to AIX and I miss some tricks that work well on other *nix flavors. I need a CTRL sequence in a ksh scripts, like ^[ (CTRL-[) and to do that I'm habit to use the ctrl-v [ , but here it doesn'...
0 votes
1 answer
248 views

nano/vi open write protected file as a unauthorized user- Can I escalate to save?

More times than I want to admit I will open a config as a non-super user and will go about making the changes I need. As soon as I save in nano, or vi I am met with permissions errors. At this point ...
1 vote
6 answers
4k views

How to set up "vi" shell environment as default

I'd like to use vi (set -o vi can do the trick) as default in my shell instead of emacs, but I do not want to put it into bash startup scripts. Why? Because I work as verification engineer and I am ...
10 votes
3 answers
3k views

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.
2 votes
1 answer
8k views

Modifying xml definition of a running KVM domain via script

How can I modify the xml definition of a VM over ssh? I know that I can do this interactively by logging into the host and using: virsh edit <domain name> But I want to automate this ...
13 votes
4 answers
4k views

Save file after forgetting to open as root / sudo vi [duplicate]

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 ...
1 vote
1 answer
420 views

Solaris "crontab -e" locking via vi

I ran into an issue yesterday with locking on Solaris and crontab editing that has me wondering what the best way to protect multiple concurrent edits of the same crontab are on Solaris. I've ...
0 votes
7 answers
3k views

vi syntax to comment out non-commented lines (cron)

Anyone know if it's possible in vi to replace only uncommented/non-blank lines with comments? If I want to replace a commented line with something I know I can use :%s/^#/##foo##/g -- but I am ...
2 votes
2 answers
272 views

How to keep the top lines of a file while scrolling down the page in vi editor

I have a file opened with vim, how do I keep the top 10 header lines at the top all the time while I scroll down the page?
2 votes
5 answers
459 views

Textmate alternative with vim? [closed]

Is there a way to use the vim editor like the mac textmate editor ? I am searching a easy configuration or plugin. a split screen or a panel for directorys currently opend files or many cool stuff ...
-1 votes
1 answer
141 views

Why does nvi think I have files being editing?

I've got a couple of FreeBSD servers that throw several copies of the following error on reboot: On Wed Oct 10 15:13:16 2012, the user root was editing a file named /tmp/crontab.s00huOAZD2 on the ...
7 votes
1 answer
2k views

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 ...
-1 votes
1 answer
227 views

is it possible to know whether someone else has opened file in ec2-linux [closed]

We guys work collaboratively. Sometimes more then 1 have opened same file in vi editor. Can I know there who else has opened that file in amazon ec2 instance? Also if I can know what changes made by ...
-2 votes
1 answer
848 views

Unable to set a cron job in Centos [closed]

I recently got an VPS to experiment, I have installed Centos and is trying to see if I can setup hostbill and run it from there. The installation all worked out well but I am stumped when it comes to ...
-3 votes
1 answer
143 views

editing files on remote server with Vi not recognised when I refresh my browser [closed]

My server is running on Apache Linux. I'm very new to this area. Is there a default folder where the website files are stored? I mean I thought I had it - the first one in the list below, but it doesn'...
6 votes
3 answers
3k views

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 ...
3 votes
1 answer
1k views

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 ...
0 votes
1 answer
284 views

how to monitor any changes to any file by using vi command

Im looking for a tools (script) for monitoring my systems for any changes on any files by using vi command. For example: one dba open alert.log with vi and modify it and save.. i need to trace these ...
4 votes
2 answers
302 views

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: %...
3 votes
1 answer
1k views

Linode Lish Shell Vim and Nano rendering troubles: lines not appearing / cursor positions wrong

I'm using a linode VPS and I just cloned one of my servers to my development server as I've done many times before. As usual SSH is inaccessible until /etc/network/interfaces is correctly updated. I ...
-2 votes
1 answer
1k views

Vi how to search for numbers [closed]

I want to search for the occurrence of 100169200 I typed /100169200 but vi says Pattern not found Edit Since the question has been downvotes, I would like to make it clear that grep can find the ...
0 votes
2 answers
3k views

cat or vi a file, hangs

we're having some issue on a SUN 5.8 machine. first of all, the server is on his network (i.e. 10.x.x.x) and we can login using an ssh server which is on another network (196.x.x.x), so there're ...
2 votes
3 answers
387 views

alias to replace a text in file

here is a practical situation.I facing some of my files where there is a common string in these files.I usually will open vi and do some thing like :%s/text/replacement/g and I have to do it in ...
3 votes
1 answer
415 views

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
1 vote
4 answers
2k views

Is linux VI editor different from vim editor

I want to use one editor which is available across all the system. Someone told me VIM is best and i tried on ubuntu and VIM was not there but vi is there. SO which one should i use
2 votes
3 answers
2k views

VI Editor on Ubuntu using VIM Short Cuts?

I installed Ubuntu and I tried to use the terminal's vi editor. The editor is using a different set of short cut keys that I'm not familiar with. Someone told me it's probably using the VIM short ...