Linux/Linux

Vim 설정 / Vim Settings

옥뀨 2020. 7. 13. 02:07

터미널에서 프로그래밍을 하기 전 마지막 단계인 Vim 설정이다.

The last step before programming in the terminal is the Vim configuration.

 

Vim 설정을 하는 이유는 가독성과 편리성을 높이고 컴파일과 디버깅을 편하게 하기 위해서이다.

The reason for setting Vim is to improve readability and convenience and to compile and debug easily.

 

centos로 접속을 한 후 터미널에서 "gcc" 와 "vim" 을 입력해보자.

After connecting to centos, type "gcc" and "vim" in the terminal.

 

명령어를 찾을 수 없다고 나올 것이다.

It will say that the command not found.

 

그럼 설치를 진행 해주어야 한다.

Then we have to proceed with the installation.

 

gcc는 컴파일을 하기 위해 사용하는 프로그램이다.

gcc is a program used to compile.

 

$ yum -y install gcc vim

Vim 설정(1) / Vim Settings(1)

설치를 완료해주었으면 ".bashrc" 파일을 열어 수정을 해보자.

Once we have completed the installation, open the ".bashrc" file and modify it.

 

굳이 수정할 필요가 없으나 vim 을 입력하는 것보다 vi 라고 입력하는게 더 편해서 해주는 작업이다.

There is no need to modify it, but typing vi is more convenient than typing vim.

 

# vi .bashrc

Vim 설정(2) / Vim Settings(2)

파일을 열고 나면 "alias" 라는 문구가 보일 것이다.

After opening the file, we should see the phrase "alias".

 

별칭을 지정해주는 것이다. "rm" 이라는 명령어를 치면 "rm -i" 명령어가 실행된다.

It is to specify an alias. When the command "rm" is entered, the command "rm -i" is executed.

 

"rm" 은 삭제 명령어고 "-i" 옵션은 묻는 옵션이다.

"rm" is the delete command and "-i" option is the option to ask.

 

필자는 vi 를 입력하면 vim이 실행되게 설정해주었다.

I set vim to run when I type vi.

 

Vim 설정(3) / Vim Settings(3)

이제 Vim 설정을 해주는데 "ls -a" 명령어를 입력하면 다른 설정파일은 있지만 Vim에 대한 설정 파일은 보이지 않는다.

Now, we are going to configure Vim. If we enter the "ls -a" command, there is another configuration file,

but the configuration file for Vim is not visible.

 

".vimrc" 파일을 만들어 Vim 설정을 해주자.

Create a ".vimrc" file and configure Vim.

 

# vi .vimrc

Vim 설정(4) / Vim Settings(4)

Vim 설정 항목은 많이 있다.

There are many Vim configuration items.

 

참고할 만한 사이트 링크를 걸어둘테니 가서 보고 자신이 쓰고 싶은 취향에 맞춰서 설정해주면 되겠다.

I'll post a link to a site that I can refer to, so I can go see it and set it up according to my preference.

 

https://medium.com/sunhyoups-story/vim-%EC%97%90%EB%94%94%ED%84%B0-%EC%9D%B4%EC%81%98%EA%B2%8C-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0-5b6b8d546017

 

필자는 꾸미는 것보다 프로그래밍용으로 사용하므로 간단하게만 설정해두었고 각 항목에 붙어있는

" 는 주석의 의미이다.

I use it for programming rather than decorating it,

so I set it up simply, and the "character is the meaning of the comment.

 

17번 18번 라인에 써있는 map은 mapping 의 약자로 단축키 설정을 해주겠다는 의미이다.

The map written on lines 17 and 18 is an abbreviation of mapping, which means that we will set a shortcut.

 

17번 라인을 해석하자면 "Ctrl + Shift + 알파벳 o" 를 단축키로 맵핑 시킬 것이고 ":w!" 로 파일을 저장 후

":!" 로 새로운 명령어를 입력받을 것이며 "gcc" 로 컴파일할 것이다.

Interpreting line 17 will use "Ctrl + Shift + Alphabet o" as a shortcut.

It will save the file with ":w!" and enter a new command with ":!" and compile with "gcc".

 

컴파일 옵션으로 "-Wall" 모든 경고를 출력하게 할 것이고 "-m32" 32비트로 컴파일 할 것이며 "-g" 디버깅 옵션을

추가할 것이다.

Compile options will print all warnings with "-Wall", compile with 32 bits with "-m32",

and add debugging options with "-g".

 

32비트로 컴파일하는 이유는 32비트로 컴파일하면 32비트 운영체제와 64비트 운영체제 둘 다 동작하며

64비트로 컴파일하면 64비트 운영체제에서만 작동하고 자료형의 크기에서도 차이가 있다.

The reason for compiling in 32-bit is that it works in both 32-bit and 64-bit operating systems

when compiled in 32-bit, but only works in 64-bit operating systems when compiled in 64-bit,

and there is also a difference in the size of data types.

 

처음 시작은 32비트로 프로그래밍하고 컴파일할 예정이다.

Initially, we will program and compile in 32 bits.

 

"%<" 파일 이름 그대로 컴파일 할 것이고 "%" 컴파일할 파일명은 파일명.c이다.

"%<" is the file name and will compile as it is, and "%" indicates the name of the file to be compiled,

which means file name.c.

 

"./%<" 컴파일된 파일을 실행 시킬 것이다.

"./%<" will run the compiled file.

 

중간중간에 들어가 있는 "<cr>" 명령어는 엔터를 의미한다.

The "<cr>" command in the middle means enter.

 

18번 라인에 입력된 명령어는 디버깅 명령어이다.

The command entered on line 18 is a debugging command.

 

Vim 설정(5) / Vim Settings(5)

저장하고 빠져나오면 모든 설정이 완료된 것이다.

When we save and exit, all settings are complete.

 

이제 프로그래밍을 시작해보자.

Let's start programming now.

'Linux > Linux' 카테고리의 다른 글

Vim 단축키 / Vim shortcuts  (0) 2020.07.09