Vi Interview Questions

5
Re: What does the /text command do? Answer /text: it will search for the string. after pressing enter it takes u to that text location. Re: Which command is used to replace many characters? Answer # 2 change command can be used to change a word/line. cw change word forward cb change word backward c$ change from cursor to end of line cL change from current line to and of screen cG change from current line to and of file or if you want to replace all occurence of some specific character :%s/oldText/newText/g Re: How to enter from command mode to insertion mode? Answer # 1 There are several commands that put the VI editor into insert mode. The most commonly used commands to get into insert mode are a and i. Re: What is the command used to replace many characters? Answer # 1 this question should bhave been for many same words that appear many times, for this press escape to go to command line, then type :%s/old_word/new_word/g g for global Re: What is the command used to replace many characters? Answer # 2 for replce many character in vi editor press esc key and then press R for replce many character. Re: what are the two different modes in vi editor? Answer # 1 Command Mode Insert Mode LastLine mode Re: what is the command used to set margin in vi editor? Answer # 2 it should be :set nu

Transcript of Vi Interview Questions

Re: What does the /text command do? Answer/text: it will search for the string. after pressing enter it takes u to that text location.

  Re: Which command is used to replace many characters? Answer# 2 change command can be used to change a word/line.

cw change word forwardcb change word backwardc$ change from cursor to end of linecL change from current line to and of screencG change from current line to and of file

or if you want to replace all occurence of some specific character

:%s/oldText/newText/g

Re: How to enter from command mode to insertion mode? Answer# 1 There are several commands that put the VI editor into insert mode. The most commonly used commands to get into insert mode are a and i.

  Re: What is the command used to replace many characters? Answer# 1 this question should bhave been for many same words that appear many times, for this press escape to go to command line, then type:%s/old_word/new_word/gg for global

      Re: What is the command used to replace many characters? Answer# 2 for replce many character in vi editor press esc key and then press R for replce many character.

  Re: what are the two different modes in vi editor? Answer# 1 Command ModeInsert ModeLastLine mode

  Re: what is the command used to set margin in vi editor? Answer# 2 it should be :set nu

  Re: what does the c$ command do from command mode? Answer# 1 c$ will begin from the character under the curser till theend of line. so when you use this command it will show you $sign at the end of the line and you can change till that point.

      Re: what does the c$ command do from command mode? Answer# 2 It will delethe whole line and go into editing mode

  Re: What is the difference between lettered buffer and temporary buffer? Answer# 1 Temporary Buffer

Deleted or copied text goes into a temporary unnamed buffer. The contents of the temporary buffer may be retrieved by using the p or P commands.

Lettered Buffers

There are 26 lettered buffers (a-z). Contents of a lettered buffer are saved until you copy or delete more characters into it, or until you quit your current vi session.

eg. From Command Mode

"ayy Copy (yank) a line into buffer letter "a""ap Put contents of lettered buffer a below the current line

  Re: How to append a file to current file? Answer# 1 to append file1 to file2. first open file1 in vi editorusing vi file1 command. then to append file1 to file 2 justuse the following command.

:w>>file2 so file 1 will be appended to file 2

      Re: How to append a file to current file? Answer# 2 Alternate approach:

If you are working in file2 and want to append file1, thanplace the cursor where you want to append the new file anduse the following command

:r file1

  Re: How to create a .exrc file in vi editor? Answer# 1 Introduction

This article presents a sample .exrc file that can be used by users of the vi editor. The .exrc file, located in your home directory, is the startup (or configuration) file for the vi editor.

The intent of this brief article is to show some of the ways you can modify the configuration of the vi editor

Please note that the .exrc file contains commands that Vi reads when you first run it. The default directory that Vi looks in for the .exrc file is your home directory. However, if you run Vi from another directory containing

a .exrc file, Vi will use the .exrc in that directory and bypass the home directory .exrc. You must precede control characters (like ^[ or ^M) with CONTROL-V. For example to enter ^M, type CONTROL-V CONTROL-M.

Some important points for .exrc files:

Do not allow any blank lines in the file or processing will stop on that line. Comments are introduced by starting a line with a double quote: " All directives, whether options, abbreviations, or key macros must all be typed on a single line. The listing below has had the lines broken up for the sake of readability. Control characters like [tab],[linefeed],[escape] can be inserted by first typing ^V (hold down Ctrl, and press V), followed by the character. For instance, for [tab], hold Ctrl and press V, release Ctrl, hit [tab]. You'll see ^I. This is evident in the listing below. For VIM the corresponsing file is .vimrc (_vimrc in case of windows)

Re: How to return to shell without leaving vi editor? Answer# 1 In the vi Press 'Esc' and ':' then Type 'shell'And you can go to shell and do different commands.To return to vi editor type 'exit' in shell prompt.

Re: What is the difference between ZZ and :wq commands? Answer# 1 I guess both do the same task..! in the sense :wq,:x and ZZare used to save the changes of edited to storage and quit..but to jot down the difference a foolish one.. :wq and :xrequires <enter> key to be pressed to fire this commandswhere as ZZ works as a shortcut (hot) key.. it some whatlike for prior commands we are requesting Vi to do the workand later command we are telling/commanding

      Re: What is the difference between ZZ and :wq commands? Answer# 2 ZZ is the command mode comand in uix to save and quit file.:wq is the execute command mode command to save and quit file.

Both does the same job

  Re: what are the different delete commands used in vi editor? Answer# 1 dd -- for delete linex - single character deletiondw - delete word

    Re: what are the different delete commands used in vi editor? Answer# 2

dd -- for delete linendd -- for delete n no of linesfrom the current cursor position(n=any number)x -- single character deletiondw -- delete word

  Re: How to replace String "a" with String "b" in whole file of the vi editor? Answer# 1 :g/string1/s//string2/g

ex: :g/a/s//b/g

      Re: How to replace String "a" with String "b" in whole file of the vi editor? Answer# 2 :%s/a/b

  Re: What is the command used to display line numbers in vi editor? Answer# 1 esc:set numberRepeating in Descriptive form

Please come to command mode by pressing escape.Put :The typoe set number and enter

You can view line nos

  Re: what are the different commands used to quit from the vi editor? Answer# 1 q! IS THE COMMAND TO QUIT FROM vi EDITOR WITHOUT SAVINGwq IS THE COMMAND TO QUIT FROM vi EDITOR WITH SAVINGq IS THE IS THE COMMAND TO QUIT FROM vi EDITOR IF YOU DONT EDIT ANYTHING AFTER OPENING THAT FILE