Skip to main content

vimrc

vimrc simple
"
" Fixed for Python virtualenv as the follow error.
" ModuleNotFoundError: No module named 'powerline'
"
python3 import sys;sys.path.append("/home/alang/.local/lib/python3.10/site-packages")
"
" Powerline with Vim
set laststatus=2
python3 from powerline.vim import setup as powerline_setup
python3 powerline_setup()                                                                                                                                                                       
python3 del powerline_setup

"
syntax on               " Enable syntax highlighting
set number              " Show line numbers
set relativenumber      " Show relative line numbers
set tabstop=4           " Set tab width to 4 spaces
set shiftwidth=4        " Set indentation width to 4 spaces
set expandtab           " Use spaces instead of tabs
set cursorline          " Highlight the current line

" Moving Lines
" Ctrl-j: Move down, Ctrl-k: Move down
nnoremap <c-j> :m .+1<CR>==
nnoremap <c-k> :m .-2<CR>==
inoremap <c-j> <Esc>:m .+1<CR>==gi
inoremap <c-k> <Esc>:m .-2<CR>==gi
vnoremap <c-j> :m '>+1<CR>gv=gv
vnoremap <c-k> :m '<-2<CR>gv=gv

" Preserve last editing position
silent! source $VIMRUNTIME/defaults.vim
vimrc advanced 
"
" minimal vimrc with no (extra) plugins
"

"regular settings
"----------------
" ui
set number
set ruler
set wildmenu
set showcmd
set showmatch

" encoding/format
set encoding=utf-8
set fileformats=unix,dos,mac

" searching
set hlsearch
set incsearch
set ignorecase
set smartcase

" indent
set shiftwidth=4
set tabstop=4
set softtabstop=4
set autoindent

" allow syntax and filetype plugins
syntax enable
filetype plugin indent on
runtime macros/matchit.vim

" Moving Lines
" Ctrl-j: Move down, Ctrl-k: Move up
nnoremap <c-j> :m .+1<CR>==
nnoremap <c-k> :m .-2<CR>==
inoremap <c-j> <Esc>:m .+1<CR>==gi
inoremap <c-k> <Esc>:m .-2<CR>==gi
vnoremap <c-j> :m '>+1<CR>gv=gv
vnoremap <c-k> :m '<-2<CR>gv=gv

" autocmds
"---------
augroup general
    autocmd!
    "keep equal proportions when windows resized
    autocmd VimResized * wincmd =
    "save cursor position in a file
    autocmd BufReadPost * if line("'\"") > 1 && line("'\"")
                \ <= line("$") | exe "normal! g'\"" | endif
augroup END

augroup languages
    autocmd!
    autocmd BufNewFile,BufRead *.bash set syntax=sh
    autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
    autocmd FileType go set noexpandtab
    autocmd FileType html :syntax sync fromstart
    autocmd FileType html,javascript,css,json,yaml,sh
                \ setlocal ts=2 sts=2 sw=2 expandtab
augroup END
Learning