|
| 1 | +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 2 | +" |
| 3 | +" ██╗ ██╗██╗███╗ ███╗██████╗ ██████╗ |
| 4 | +" ██║ ██║██║████╗ ████║██╔══██╗██╔════╝ |
| 5 | +" ██║ ██║██║██╔████╔██║██████╔╝██║ |
| 6 | +" ╚██╗ ██╔╝██║██║╚██╔╝██║██╔══██╗██║ |
| 7 | +" ╚████╔╝ ██║██║ ╚═╝ ██║██║ ██║╚██████╗ |
| 8 | +" ╚═══╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ |
| 9 | +" |
| 10 | +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 11 | + |
| 12 | +" Disable compatibility with vi which can cause unexpected issues. |
| 13 | +set nocompatible |
| 14 | + |
| 15 | +" Enable type file detection. Vim will be able to try to detect the type of file is use. |
| 16 | +filetype on |
| 17 | + |
| 18 | +" Enable plugins and load plugin for the detected file type. |
| 19 | +filetype plugin on |
| 20 | + |
| 21 | +" Load an indent file for the detected file type. |
| 22 | +filetype indent on |
| 23 | + |
| 24 | +" Turn syntax highlighting on. |
| 25 | +syntax on |
| 26 | + |
| 27 | +" Add numbers to the file. |
| 28 | +set number |
| 29 | + |
| 30 | +" Highlight cursor line underneath the cursor horizontally. |
| 31 | +set cursorline |
| 32 | + |
| 33 | +" Highlight cursor line underneath the cursor vertically. |
| 34 | +set cursorcolumn |
| 35 | + |
| 36 | +" Set shift width to 4 spaces. |
| 37 | +set shiftwidth=4 |
| 38 | + |
| 39 | +" Set tab width to 4 columns. |
| 40 | +set tabstop=4 |
| 41 | + |
| 42 | +" Use space characters instead of tabs. |
| 43 | +set expandtab |
| 44 | + |
| 45 | +" Do not save backup files. |
| 46 | +set nobackup |
| 47 | + |
| 48 | +" Do not let cursor scroll below or above N number of lines when scrolling. |
| 49 | +set scrolloff=10 |
| 50 | + |
| 51 | +" Do not wrap lines. Allow long lines to extend as far as the line goes. |
| 52 | +set nowrap |
| 53 | + |
| 54 | +" While searching though a file incrementally highlight matching characters as you type. |
| 55 | +set incsearch |
| 56 | + |
| 57 | +" Ignore capital letters during search. |
| 58 | +set ignorecase |
| 59 | + |
| 60 | +" Override the ignorecase option if searching for capital letters. |
| 61 | +" This will allow you to search specifically for capital letters. |
| 62 | +set smartcase |
| 63 | + |
| 64 | +" Show partial command you type in the last line of the screen. |
| 65 | +set showcmd |
| 66 | + |
| 67 | +" Show the mode you are on the last line. |
| 68 | +set showmode |
| 69 | + |
| 70 | +" Show matching words during a search. |
| 71 | +set showmatch |
| 72 | + |
| 73 | +" Use highlighting when doing a search. |
| 74 | +set hlsearch |
| 75 | + |
| 76 | +" Set the commands to save in history default number is 20. |
| 77 | +set history=1000 |
| 78 | + |
| 79 | +" Enable auto completion menu after pressing TAB. |
| 80 | +set wildmenu |
| 81 | + |
| 82 | +" Make wildmenu behave like similar to Bash completion. |
| 83 | +set wildmode=list:longest |
| 84 | + |
| 85 | +" There are certain files that we would never want to edit with Vim. |
| 86 | +" Wildmenu will ignore files with these extensions. |
| 87 | +set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx |
| 88 | + |
| 89 | +" PLUGINS ---------------------------------------------------------------- {{{ |
| 90 | + |
| 91 | +call plug#begin('~/.vim/plugged') |
| 92 | + |
| 93 | + Plug 'dense-analysis/ale' |
| 94 | + |
| 95 | + Plug 'preservim/nerdtree' |
| 96 | + |
| 97 | +call plug#end() |
| 98 | + |
| 99 | +" }}} |
| 100 | + |
| 101 | +" MAPPINGS --------------------------------------------------------------- {{{ |
| 102 | + |
| 103 | +" Set the backslash as the leader key. |
| 104 | +let mapleader = '\' |
| 105 | + |
| 106 | +" Press \\ to jump back to the last cursor position. |
| 107 | +nnoremap <leader>\ `` |
| 108 | +
|
| 109 | +" Press \p to print the current file to the default printer from a Linux operating system. |
| 110 | +" View available printers: lpstat -v |
| 111 | +" Set default printer: lpoptions -d <printer_name> |
| 112 | +" <silent> means do not display output. |
| 113 | +nnoremap <silent> <leader>p :%w !lp<CR> |
| 114 | +
|
| 115 | +" Type jj to exit insert mode quickly. |
| 116 | +inoremap jj <Esc> |
| 117 | +
|
| 118 | +" Press the space bar to type the : character in command mode. |
| 119 | +nnoremap <space> : |
| 120 | +
|
| 121 | +" Pressing the letter o will open a new line below the current one. |
| 122 | +" Exit insert mode after creating a new line above or below the current line. |
| 123 | +nnoremap o o<esc> |
| 124 | +nnoremap O O<esc> |
| 125 | +
|
| 126 | +" Center the cursor vertically when moving to the next word during a search. |
| 127 | +nnoremap n nzz |
| 128 | +nnoremap N Nzz |
| 129 | +
|
| 130 | +" Yank from cursor to the end of line. |
| 131 | +nnoremap Y y$ |
| 132 | +
|
| 133 | +" Map the F5 key to run a Python script inside Vim. |
| 134 | +" We map F5 to a chain of commands here. |
| 135 | +" :w saves the file. |
| 136 | +" <CR> (carriage return) is like pressing the enter key. |
| 137 | +" !clear runs the external clear screen command. |
| 138 | +" !python3 % executes the current file with Python. |
| 139 | +nnoremap <f5> :w <CR>:!clear <CR>:!python3 % <CR> |
| 140 | +
|
| 141 | +" You can split the window in Vim by typing :split or :vsplit. |
| 142 | +" Navigate the split view easier by pressing CTRL+j, CTRL+k, CTRL+h, or CTRL+l. |
| 143 | +nnoremap <c-j> <c-w>j |
| 144 | +nnoremap <c-k> <c-w>k |
| 145 | +nnoremap <c-h> <c-w>h |
| 146 | +nnoremap <c-l> <c-w>l |
| 147 | +
|
| 148 | +" Resize split windows using arrow keys by pressing: |
| 149 | +" CTRL+UP, CTRL+DOWN, CTRL+LEFT, or CTRL+RIGHT. |
| 150 | +noremap <c-up> <c-w>+ |
| 151 | +noremap <c-down> <c-w>- |
| 152 | +noremap <c-left> <c-w>> |
| 153 | +noremap <c-right> <c-w>< |
| 154 | +
|
| 155 | +" NERDTree specific mappings. |
| 156 | +" Map the F3 key to toggle NERDTree open and close. |
| 157 | +nnoremap <F3> :NERDTreeToggle<cr> |
| 158 | +
|
| 159 | +" Have nerdtree ignore certain files and directories. |
| 160 | +let NERDTreeIgnore=['\.git$', '\.jpg$', '\.mp4$', '\.ogg$', '\.iso$', '\.pdf$', '\.pyc$', '\.odt$', '\.png$', '\.gif$', '\.db$'] |
| 161 | + |
| 162 | +" }}} |
| 163 | + |
| 164 | +" VIMSCRIPT -------------------------------------------------------------- {{{ |
| 165 | + |
| 166 | +" Enable the marker method of folding. |
| 167 | +augroup filetype_vim |
| 168 | + autocmd! |
| 169 | + autocmd FileType vim setlocal foldmethod=marker |
| 170 | +augroup END |
| 171 | + |
| 172 | +" If the current file type is HTML, set indentation to 2 spaces. |
| 173 | +autocmd Filetype html setlocal tabstop=2 shiftwidth=2 expandtab |
| 174 | + |
| 175 | +" If Vim version is equal to or greater than 7.3 enable undofile. |
| 176 | +" This allows you to undo changes to a file even after saving it. |
| 177 | +if version >= 703 |
| 178 | + set undodir=~/.vim/backup |
| 179 | + set undofile |
| 180 | + set undoreload=10000 |
| 181 | +endif |
| 182 | + |
| 183 | +" You can split a window into sections by typing `:split` or `:vsplit`. |
| 184 | +" Display cursorline and cursorcolumn ONLY in active window. |
| 185 | +augroup cursor_off |
| 186 | + autocmd! |
| 187 | + autocmd WinLeave * set nocursorline nocursorcolumn |
| 188 | + autocmd WinEnter * set cursorline cursorcolumn |
| 189 | +augroup END |
| 190 | + |
| 191 | +" If GUI version of Vim is running set these options. |
| 192 | +if has('gui_running') |
| 193 | + |
| 194 | + " Set the background tone. |
| 195 | + set background=dark |
| 196 | + |
| 197 | + " Set the color scheme. |
| 198 | + colorscheme molokai |
| 199 | + |
| 200 | + " Set a custom font you have installed on your computer. |
| 201 | + " Syntax: <font_name>\ <weight>\ <size> |
| 202 | + set guifont=Monospace\ Regular\ 12 |
| 203 | + |
| 204 | + " Display more of the file by default. |
| 205 | + " Hide the toolbar. |
| 206 | + set guioptions-=T |
| 207 | + |
| 208 | + " Hide the the left-side scroll bar. |
| 209 | + set guioptions-=L |
| 210 | + |
| 211 | + " Hide the the left-side scroll bar. |
| 212 | + set guioptions-=r |
| 213 | + |
| 214 | + " Hide the the menu bar. |
| 215 | + set guioptions-=m |
| 216 | + |
| 217 | + " Hide the the bottom scroll bar. |
| 218 | + set guioptions-=b |
| 219 | + |
| 220 | + " Map the F4 key to toggle the menu, toolbar, and scroll bar. |
| 221 | + " <Bar> is the pipe character. |
| 222 | + " <CR> is the enter key. |
| 223 | + nnoremap <F4> :if &guioptions=~#'mTr'<Bar> |
| 224 | + \set guioptions-=mTr<Bar> |
| 225 | + \else<Bar> |
| 226 | + \set guioptions+=mTr<Bar> |
| 227 | + \endif<CR> |
| 228 | +
|
| 229 | +endif |
| 230 | + |
| 231 | +" }}} |
| 232 | + |
| 233 | +" STATUS LINE ------------------------------------------------------------ {{{ |
| 234 | + |
| 235 | +" Clear status line when vimrc is reloaded. |
| 236 | +set statusline= |
| 237 | + |
| 238 | +" Status line left side. |
| 239 | +set statusline+=\ %F\ %M\ %Y\ %R |
| 240 | + |
| 241 | +" Use a divider to separate the left side from the right side. |
| 242 | +set statusline+=%= |
| 243 | + |
| 244 | +" Status line right side. |
| 245 | +"set statusline+=\ ascii:\ %b\ hex:\ 0x%B\ row:\ %l\ col:\ %c\ percent:\ %p%% |
| 246 | + |
| 247 | +" Show the status on the second to last line. |
| 248 | +set laststatus=2 |
| 249 | +set termguicolors |
| 250 | +" }}} |
0 commit comments