You are on page 1of 2

VIM ASSIGNMENT

Q: Please find out the vim commands to do the following.


For Q 1- 10 : use REF1

1. Find the number of occurrence of the word “integrated” in the file.


2. Delete all the lines containing the word “SoC”.
3. Delete all lines beginning with the word “The”.
4. Delete all lines except those beginning with “The”.
5. Replace the word “technology” with “technologies” only from lines 11 to 22.
6. Wherever there is a word “chips” in any line, add one more line “very large scale
integration” just below that line.
7. How do you create a shortcut to:
a. To quit the file – QQ in command mode
b. To save the file – WW in command mode
8. Copy first half of the contents of this file to another file with name backup.rpt ( Without
closing the current file )
9. How to go to the 9th line of the document?
10. Open the file backup.rpt by staying in the current file and without quiting.
11. How to find the current file name and the total number of lines in vim?
12. Suppose you have two files 1.tcl and 2.tcl. Currently, you have opened 1.tcl. How will
you insert the contents of 2.tcl to this file?
13. If you have a file path inside the current file, how will you open that file without closing
the current one?
14. Why are macros used in Vim?
15. Using macro, insert a “hi” at the beginning of the first 5 lines of the file REF1.
16. Why are marks used in Vim?
17. In visual mode, how will you change the case of a line/ word?
18. Find out how to
a. Jump to the end of a line
b. Jump to the start of a line
c. Go to the last line of the document
d. Go to the first line of the document
e. Insert at the beginning of the line
f. Insert at the end of the line
g. Join a line below to the current one with a space in between
h. Delete a line till the end of the document from where the cursor is placed
i. Copy a line
j. Delete blank lines
k. To insert below the current line
l. To insert above current line
m. To paste above current line
n. To paste below current line
o. Page down (half the screen) in vim
p. Jump to 10 lines below the cursor position
q. Jump to 10 lines above the cursor position
r. Delete the contents inside the bracket ”(“ when the cursor is inside the bracket
s. List all the words (from the current file) starting with a specific letter (say ‘c’) in
insert mode.
19. Based on the file REF2
a. Change the "," to space in the whole file     
b. Sort the file based on their IDs ( in decreasing order)    
c. Print only the names and their hometown for those whose IDs are less than
2000.  
20. After changing the “,” to space in REF2 , Save all the name of persons (first column) to
register “N” using macro recording and paste it at the end of the file.

You might also like