Last active
November 2, 2025 11:38
-
-
Save islam-kamel/0a0623d514814597d7565d51cfdc0615 to your computer and use it in GitHub Desktop.
Vim Configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Disable compatibility with vi which can cause unexpected issues. | |
| set nocompatible | |
| " Enable type file detection. Vim will be able to try to detect the type of | |
| " file in use. | |
| filetype on | |
| " Enable plugins and load plugin for the detected file type. | |
| filetype plugin on | |
| " Load an indent file for the detected file type. | |
| filetype indent on | |
| " Syntax highlight | |
| syntax on | |
| let python_highlight_all=1 | |
| " Show Line Number | |
| set number | |
| " Show Current Line Postion | |
| set relativenumber | |
| " Set shift width to 4 spaces. | |
| set shiftwidth=4 | |
| " Set tab width to 4 columns. | |
| set tabstop=4 | |
| " Set auto indentation | |
| set autoindent | |
| " Use space characters instead of tabs. | |
| set expandtab | |
| " Do not save backup files. | |
| set nobackup | |
| " Do not let cursor scroll below or above N number of lines when scrolling. | |
| set scrolloff=10 | |
| " Do not wrap lines. Allow long lines to extend as far as the line goes. | |
| set nowrap | |
| " While searching though a file incrementally highlight matching characters as | |
| " you type. | |
| set incsearch | |
| " Ignore capital letters during search. | |
| set ignorecase | |
| " Override the ignorecase option if searching for capital letters. | |
| " This will allow you to search specifically for capital letters. | |
| set smartcase | |
| " Show partial command you type in the last line of the screen. | |
| set showcmd | |
| " Show the mode you are on the last line. | |
| set showmode | |
| " Show matching words during a search. | |
| set showmatch | |
| " Use No highlighting when doing a search. | |
| set nohlsearch | |
| " Set the commands to save in history default number is 20. | |
| set history=1000 | |
| " Search down into subfolders | |
| " Providers tab-completion for all file-related tasks | |
| set path+=** | |
| " Show right column for error hint | |
| set signcolumn=yes | |
| " Show column for line length | |
| set colorcolumn=80 | |
| " Save file in buffer | |
| set hidden | |
| " Enable auto completion menu after pressing TAB. | |
| set wildmenu | |
| " Make wildmenu behave like similar to Bash completion. | |
| set wildmode=list:longest | |
| " There are certain files that we would never want to edit with Vim. | |
| " Wildmenu will ignore files with these extensions. | |
| set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx | |
| " Folding code | |
| set foldmethod=indent | |
| set foldlevel=99 | |
| " Make yanking and deleting to the system | |
| set clipboard=unnamedplus | |
| " Press Space to toggle fold | |
| nnoremap <space> za | |
| call plug#begin() | |
| Plug 'dense-analysis/ale' | |
| Plug 'preservim/nerdtree' | |
| Plug 'jistr/vim-nerdtree-tabs' | |
| Plug 'nvie/vim-flake8' | |
| Plug 'vim-scripts/indentpython.vim' | |
| Plug 'vim-syntastic/syntastic' | |
| Plug 'turbio/bracey.vim' | |
| "Plug 'vim-scripts/AutoComplPop' | |
| Plug 'ycm-core/YouCompleteMe' | |
| Plug 'kien/ctrlp.vim' | |
| Plug 'prettier/vim-prettier', { | |
| \ 'do': 'yarn install --frozen-lockfile --production', | |
| \ 'for': ['javascript', 'typescript', 'css', 'scss', 'json', 'markdown', 'html']} | |
| call plug#end() | |
| " Load all plugin | |
| packloadall | |
| " Set Indent size for file | |
| au BufNewFile, BufRead *.py | |
| \ set softtabstop=4 | |
| \ set textwidth=120 | |
| \ set fileformat=unix | |
| " Set Indent size for html, css and js | |
| au BufNewFile, BufRead *.html, *.css, *.js* | |
| \ set softtabstop=4 | |
| \ set shiftwidth=4 | |
| \ set tabstop=4 | |
| \ set softtabstop=4 | |
| \ set fileformat=unix | |
| " Remove white space ---------------- {{{ | |
| fun! TrimWhiteSpace() | |
| let l:save = winsaveview() | |
| keeppatterns %s/\s\+$//e | |
| call winrestview(l:save) | |
| endfun | |
| augroup THE_PRIMEAGEN | |
| autocmd! | |
| autocmd BufWritePre * :call TrimWhiteSpace() | |
| augroup END | |
| "}}} | |
| " MAPPINGS ------------------------ {{{ | |
| " Set the backslash as the leader key. | |
| let mapleader = ',' | |
| " type \ to off highlight search | |
| nnoremap <leader>,, :nohlsearch<CR> | |
| " Press .. to jump back to the last cursor position. | |
| nnoremap <leader>, `` | |
| " Type jj to exit insert mode quickly. | |
| inoremap jj <Esc> | |
| " Type [ to go to next tab, type ] to go to previose tab | |
| nnoremap <leader>[ :tabn<CR> | |
| nnoremap <leader>] :tabp<CR> | |
| " Switch bettwen buffers type .A | |
| noremap <leader>a :bnext<LF> | |
| " Center the cursor vertically when moving to the next word during a search. | |
| nnoremap n nzz | |
| nnoremap N Nzz | |
| " Yank from curssor to end of line. | |
| nnoremap Y y$ | |
| " Map the F5 key to run a script inside Vim. | |
| " I map F5 to a chain of commands here. | |
| " :w saves the file. | |
| " <CR> (carriage return) is like pressing the enter key. | |
| " !clear runs the external clear screen command. | |
| " !3 % executes the current file with Python. | |
| if has('win32') | |
| nnoremap <f5> :w <CR>:!clear <CR>:!python % <CR> | |
| else | |
| nnoremap <f5> :w <CR>:!clear <CR>:!python3 % <CR> | |
| endif | |
| " You Can split the window in Vim by typing :split or :vsplit. | |
| " Navigate the split view easier by pressing CTRL+j, CTRL+k, CTRL+h, or CTRL+l. | |
| nnoremap <c-j> <c-w>j | |
| nnoremap <c-k> <c-w>k | |
| nnoremap <c-h> <c-w>h | |
| nnoremap <c-l> <c-w>l | |
| " Resize split windows using arrow keys by pressing: | |
| " CTRL+UP, CTRL+DOWN, CTRL+LEFT, or CTRL+RIGHT. | |
| noremap <c-up> <c-w>+ | |
| noremap <c-down> <c-w>- | |
| noremap <c-left> <c-w>> | |
| noremap <c-right> <c-w>< | |
| " NERDTree specific mappings. | |
| " Map the F3 key to toggle NERDTree open and close. | |
| nnoremap <F3> :NERDTreeToggle<cr> | |
| " Have nerdtree ignore certain files and directories. | |
| let NERDTreeIgnore=['\.git$', '\.jpg$', '\.mp4$', '\.ogg$', '\.iso$', '\.pdf$', '\.pyc$', '\.odt$', '\.png$', '\.gif$', '\.db$'] | |
| " Change colorScheme | |
| " Tpye \d to switch to dark scheme | |
| " Type \l to switch to light scheme | |
| nnoremap <leader>d :colorscheme islam <CR> | |
| nnoremap <leader>l :colorscheme default <CR> | |
| " Ycm Configeration | |
| let g:ycm_autoclose_preview_window_after_completion=1 | |
| let g:ycm_enable_inlay_hints=1 | |
| map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR> | |
| "" Navigate the complete menu items like CTRL+n / CTR+p would | |
| "inoremap <expr> <Down> pumvisible() ? "<C-n>" :"<Down>" | |
| "inoremap <expr> <Up> pumvisible() ? "<C-p>" :"<Up>" | |
| " | |
| "" Select the complete menu item like CTRL+y would | |
| "inoremap <expr> <CR> pumvisible() ? "<C-y>" :"<CR>" | |
| "inoremap <expr> <Tab> pumvisible() ? "<C-y>" : "<Tab>" | |
| " | |
| "" Cancel the menu item like CTRL+e would | |
| "inoremap <expr> <Left> pumvisible() ? "<C-e>" : "<Left>" | |
| "}}} | |
| " VIMSCRIPT --------------------------------------- {{{ | |
| " If Vim version is equal to or greater than 7.3. | |
| " enable undow and set custome backup and swap path | |
| if version >= 703 | |
| if !isdirectory($HOME.'/.vim_temp') | |
| call mkdir($HOME.'/.vim_temp') | |
| call mkdir($HOME.'/.vim_temp/.backup') | |
| call mkdir($HOME.'/.vim_temp/.undo') | |
| call mkdir($HOME.'/.vim_temp/.swap') | |
| endif | |
| set directory=$HOME/.vim_temp/.swap | |
| set undodir=$HOME/.vim_temp/.undo | |
| set backupdir=$HOME/.vim_temp/.backup | |
| set undofile | |
| set undoreload=10000 | |
| endif | |
| " }}} | |
| " STATUS LINE ---------------------------------- {{{ | |
| " Clear status line when vimrc is reloaded. | |
| set statusline= | |
| " Status line left side. | |
| set statusline+=\ %F\ %M\ %Y\ %R | |
| " Use a divider to separate the left side from the right side. | |
| set statusline+=%= | |
| " Status line right side. | |
| set statusline+=\ ascii:\ %b\ hex:\ 0x%B\ row:\ %l\ col:\ %c\ percent:\ %p%% | |
| " Show the status on the second to last line. | |
| set laststatus=2 | |
| " }}} | |
| " ALE -------------------------------------- {{{ | |
| let g:ale_linters={'python':['flake8']} | |
| let g:ale_fixers={'python':['black', 'isort'], 'javascript':['prettier'], 'html':['prettier'], 'markdown':['prettier'], 'css':['prettier'], 'typescript':['prettier'], 'scss':['prettier']} | |
| nnoremap <leader>f :ALEFix<CR> | |
| " }}} | |
| " AutoComplate ----------------------------- {{{ | |
| "let g:ale_completion_enabled = 1 | |
| set complete+=kspell | |
| set completeopt=menuone,longest | |
| set shortmess+=c | |
| " }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment