Skip to main content

awesome vi editor

"vi" is not an ordinary editor. it is a popular among programmers.
in our lab most of them struggle to do copy, paste like simple things in it..
it's hard to get for the first time, but later only we can realize how
awesome the "vi" is.
my fav. commands:
vi has two modes:
1. command mode (press esc)
     in command mode our cursor will point at the bottom followed by :
2. edit mode (press i)
     normal edit mode we can type whatever we want


in command mode:
vi filename.cc  -> to create a new file
h -> left
j ->  down
k -> up
l -> right
:w -> to save
:q  -> to quit
:q! -> quit without saving
dw -> delete a single word from cursor
dd  -> delete whole line
:!g++ file.cc -o file  -> this one will compile our code without closing our file. actual syntax is :!command
where we can execute terminal commands in it. like ls, date, cal etc.

:set autoindent  -> automatically indent our source code
:set number  -> set line numbers
:set hlsearch  -> enable highlight search

Comments

Popular posts from this blog

ARP/RARP full simulation program

server.c #include "stdio.h" #include "stdlib.h" #include "string.h" #include "sys/types.h" #include "sys/socket.h" #include "arpa/inet.h" #include "netinet/in.h" #define SA struct sockaddr struct IPmac { char ip[100]; char mac[100]; }; int main() { int sockfd,len,i; struct sockaddr_in servaddr; char buff[30],temp[30],ip[30],mac[30];

Configure opendns in ubuntu 12.04

Today i have changed my dns server name to opendns. which is alternative to default dns and it provide more secure, faster browsing experience. What is opendns? OpenDNS is the leading provider of Internet security and DNS services Industry leading malware and botnet protection Award winning Web filtering Faster, reliable, more secure DNS Ultra-reliable, globally distributed cloud network Simple, Smart, Easy How to configure opendns in ubuntu 12.04: open terminal and type sudo nano /etc/resolv.conf enter your password and change these lines   nameserver 208.67.222.222  nameserver 208.67.220.220 to use google public dns use 8.8.8.8, 8.8.4.4 instead of 208.67.222.222, 208.67.220.220 simple isn't..! now see your facebook load faster than before. opendns comes with parental control, so never worry about unwanted websites, and your childrens are safe now. to check your dns changed successfully goto welcome.opendns.com

Given a string, reverse only vowels in it; leaving rest of the string as it is

/* Given a string, reverse only vowels in it; leaving rest of the string as it is. Input : abcdef Output : ebcdaf */ import java.io.*; import java.util.*; public class VowelReverse { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); String vowels = ""; String ans = ""; int arr[] = new int[str.length()]; for(int i=0;i<str.length();i++) { if(str.charAt(i)=='a' || str.charAt(i)=='e' || str.charAt(i)=='i' || str.charAt(i)=='o' || str.charAt(i)=='u') { vowels+=str.charAt(i); arr[i]=1; } } String revVowels = new StringBuffer(vowels).reverse().toString(); int j=0; for(int i=0;i<str.length();i++) { if(arr[i]!=1) { ans+=str.charAt(i); } else { ans+=revVowels.charAt(j); j++; } } System.out.println(ans); } }