vim-config.md (3338B) - raw
1 %% 2 title: "vim: The keyboard driven text editor" 3 date: "04-Mar-2021" 4 %% 5 6 ![Vim logo](vim_logo.png "Vim logo"){.article-icon} 7 8 # The keyboard driven text editor 9 10 If we think for a moment about software we are going to realize that the 11 core of every program is just plain text, literally, just words in a 12 file that someone wrote, this webpage is just text interpreted by 13 your web-browser, whose also just plain text. 14 15 The way we tell computers what to do is with text, so in order to 16 write that text we need a set of basic tools, one of which is a text editor, 17 and this is were Vim is known for. 18 19 Vim is just a console text editor, "console" because vim can only be executed 20 from the commandline (altough you can find distributions like gvim, which has 21 it's own window), a benefit of this is that, it's very lightweight in terms of 22 system resources. The term Vim stands for Vi IMproved, Vim is a rewrite and 23 improved version of Vi, a console text editor that dates from 1978, it's very 24 similar to vim but with less features. 25 26 If you installed Vim and you don't know how to move around or insert text, I'm 27 only going to tell two things, first, how to exit, press esc a couple of times 28 and also Ctrl+C, just to make sure that you are on normal mode, then type 29 \`:wq!\` and press enter. I'm also going to tell you how to run vim tutor, just 30 execute \`vimtutor\` from the commandline. Vim tutor is a very good tutorial 31 included with vim, it teaches you how to use vim in an interactive way. 32 33 ## Vim configuration 34 35 Vim is also highly configurable, you can do configure vim by editing the 36 *.vimrc* text file, which should be in you home directory in Linux or BSD based 37 OSs, if not, you can *create* a new blank one and start from zero. 38 39 You can search for vim settings or copy from other's config files, you can also 40 check out my [vim config 41 file](https://github.com/mjkloeckner/dotfiles/blob/master/.vimrc) and take out 42 the parts that would fit your needs. The basic settings are almost present in 43 every config file like: 44 45 ```vim 46 set syntax=on 47 set encoding=utf-8 48 set tabstop=4 49 set shiftwidth=4 50 set number 51 set mouse+=a 52 ``` 53 54 ## Vim plugins 55 56 By default Vim comes with a lot of features missing, for example, a key binding 57 to comment a line, or auto close brackets, parenthesis, etc, this features can 58 be enabled by installing *plugins*. 59 60 Vim plugins are like pieces of other's config files that you can include in 61 yours. The simpler way of managing plugins is with a plugin manager, I use 62 [vim-plug](https://github.com/junegunn/vim-plug). 63 64 ### Installing a plugin 65 66 First install vim-plug or any other vim plugin manager, for vim-plug enter the 67 link I left you above, and follow the instructions. For any other plugin manger 68 I think it would be pretty similar. After you got a plugin manager installed 69 simply call the plugins that you want from you .vimrc file, for example I'm 70 using vim-plug and the section where I call the plugins in my .vimrc file looks 71 like this: 72 73 ```vim 74 Plug 'christoomey/vim-tmux-navigator' 75 Plug 'justinmk/vim-syntax-extra' 76 Plug 'tpope/vim-commentary' 77 Plug 'tpope/vim-surround' 78 Plug 'jiangmiao/auto-pairs' 79 Plug 'preservim/nerdtree' 80 Plug 'morhetz/gruvbox' 81 Plug 'alvan/vim-closetag' 82 Plug 'hankchiutw/nerdtree-ranger.vim' 83 ``` 84 85 then, in the case of vim-plug, you need to run `:PlugInstall` to install all the 86 new plugins added.