Monday, October 14, 2013

Setting explanation

If you don't like new setting, you can choose what to use.

1. set nobackup
It is not going to create back up file with extension'.swp'.

When you open your file on matrix, sometimes it might lock you to use it.
This is because you have a back up file.
When you change something opening this file on another screen
or whenever it crashes, it automatically creates back up file.
nobackup will prevent to create it.

2. set nocompatible
It is to ward off unexpected things that you have made.


3. set hlsearch
    set incsearch
When you search words/strings while using vi/vim,
it will highlight those words/strings.


4.set ignorecase 
Again, when you search something, it will ignore cases.
ex) If you search for 'hello', it will also look for 'Hello', 'HELLO', etc.


5.set softtabstop=2 
It will insert 2 spaces instead of tab, when you press tab key.


6.set ts=2
It sets your tab size 2.


7. set shiftwidth=2 
    set expandtab

It will display any tab key as 2 spaces.

**5,6,7 look similar, but their purposes are different.
You might need those things to align clearly.



8. set ruler 
It will show your cursor position (col, row) at the right bottom.


9. set scrolloff=20 
It will move scroll left/right when your cursor is 20 positions before the edge of the left/right screen.


10. set sidescrolloff=20 
It will scroll down or up when your cursor is 20 lines before the edge of the bottom/top screen.


set wrap set backspace=2 colorscheme desert syntax on hi WarningMsg ctermfg=15 ctermbg=12 guifg=White guibg=Red gui=NONE

★syntax on : will change your code colorful, and more readable.






Tip: Vi(Vim) setting

When you use Vim in Cygwin, it might look ugly.
Its basic setting is not user friendly setting.

This is tip to change it easier to use.

Step 1. Go to your Home. 
(If you do not know where your home is, just press 'cd' on the command line)

Step 2. Create/Open .vimrc file (You can check if you have it with 'ls -a' command)

Step 3. Copy those setting below

set nobackup
set nocompatible
set hlsearch
set ignorecase
set softtabstop=2
set ts=2
set shiftwidth=2
set expandtab
set ruler
set incsearch
set scrolloff=20
set sidescrolloff=20
set wrap
set backspace=2
colorscheme desert
syntax on
hi WarningMsg ctermfg=15 ctermbg=12 guifg=White guibg=Red gui=NONE


Step 4. Save your .vimrc file (Type ':wq' in the command mode)



Now vi/vim becomes easier to code.


I will explain about those settings in the next post.

Tuesday, October 1, 2013

Basic Math Program

#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
using namespace std;
#define NUM_OF_ARGUMENTS 4
void ErrorMessages(){
  cout<<"<number> <+-x/> <number><ENTER>"<<endl;
}
int main(int count, char* argv[]){
  double num1,num2;
  char operand;
  if( argv[2] != NULL)
    operand = argv[2][0];
  else{
    ErrorMessages();
    return 0;
  }
  if(count==NUM_OF_ARGUMENTS){
    if(sscanf(argv[1],"%lf",&num1)==1&&sscanf(argv[3],"%lf",&num2)==1){
      switch (operand) {
        case '+': cout << num1+num2<<endl; break;
        case '-': cout << num1-num2<<endl; break;
        case 'x': cout << num1*num2<<endl; break;
        case '/': cout << num1/num2<<endl; break;
        default: ErrorMessages(); break;
      }
    }
    else{
      ErrorMessages();
      return 0;
    }
  }
  else
    ErrorMessages();

  return 0;
}

Sunday, September 22, 2013

Install Cygwin, vi(vim), gcc

What is Cygwin?

  Cygwin is a Unix-like environment and command-line interface for Microsoft Windows.
 

You can work on your projects on your local computer without internet connection.



Installation Steps



1) Go to this website: http://cygwin.com/install.html

2) Click setup-x86.exe if you have 32-bit windows. For 64-bit windows users, click setup-x86_64 to download.

 


3) When you finish downloading, click 'setup-x86_64' file to set it up. (Mine is 64 bit)





4) Click next until you get this screen. (You are going to use default setting. If you need, you can change settings.)

5) Choose any sites that you want and click Next.




6) Follow the screen above.
    ** Mine says 'keep' instead of the number I said. This is because mine is already installed.

    Search for 'vim'
    vim:VI Improved - enhanced vi editor should be 7.3.1314-1
    vim-common: Vi IMproved - enhanced vi editor (common runtime) should be 7.3.1314-1

7) Click next




 8) Finish installation




9) Start installation again to set gcc

    Search for 'gcc'
    gcc-core: GNU Compiler Collection (C. OpenMP) should be 4.8.1-3
    gcc-g++: GNU Compiler Collection (Objective-C) should be 4.8.1-3
    libgcc1: GCC runtime library should be 4.8.1-3