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

using namespace std;
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];
    return 0;
      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;
      return 0;

  return 0;