" this file is copied from .vim/.vimrc
"
set nocompatible
syntax on " turn on syntax highlighting
set ruler " diplay cursor position in the status bar
set nowrap " no line wrap
set textwidth=0 " to stop automatical text wraping when
set wrapmargin=0 " typing long lines
" ukrainian to english keys mapping so that all normal mode commands work fine for ukrainian keys
" if required add more mappings where each pair should be as following:
" ФA - here ukrainian Ф is mapped to english A
set expandtab " to insert space characters whenewer tab key is pressed
mapclear " clear all mappings
" CSS autocomplete:
" To use it, press Ctrl + x followed by Ctrl + o while partially typing CSS
" codes
autocmd FileType js set omnifunc=csscomplete#CompleteCSS
" nice autocompletion feature, for example when user is opening a
" file with e: or tabe: and presses Tab to autocomplete instead of togling
" available choices it will just show them all and user is able to proceed
" more easily
" to forcibly use it press Ctrl + d
set wildmenu
set wildmode=longest,list,full
" git commit - autocomplete for commit message (inserts ticket name from branch name)
autocmd! BufReadPost COMMIT_EDITMSG :call feedkeys('A ') | 0read !git rev-parse --abbrev-ref HEAD | sed 's/\([A-Z]*-[0-9]*\).*/\#\1/'
au BufNewFile,BufRead *.mjs set filetype=javascript
au BufNewFile,BufRead *.ts set filetype=javascript
au BufNewFile,BufRead *.tsx set filetype=javascript
au BufNewFile,BufRead *.jsx set filetype=javascript
"
"
" => pathogen - plugin manager
" https://github.com/tpope/vim-pathogen.git
execute pathogen#infect()
" => netrw - default plugin
let g:netrw_liststyle=1
let g:netrw_ftp_cmd="ftp -p" " enable passive mode for ftp connections
" => ftplugin - default plugin
filetype plugin on
filetype plugin indent on
" => fugitive
" git clone git@github.com:tpope/vim-fugitive.git ~/.vim/bundle/vim-fugitive
set diffopt+=vertical
" => gitv
" git clone https://github.com/gregsexton/gitv.git ~/.vim/bundle/gitv
let g:Gitv_OpenHorizontal = 1
let g:Gitv_OpenPreviewOnLaunch = 0
set lazyredraw
let g:Gitv_TruncateCommitSubjects = 1
" => simpledb
" git clone https://github.com/ivalkeen/vim-simpledb ~/.vim/bundle/simpledb
" => html5
" git clone https://github.com/othree/html5.vim.git ~/.vim/bundle/html5.vim
" => vim-es6 EcmaScript 6 highlighting
" git clone https://github.com/isRuslan/vim-es6.git ~/.vim/bundle/vim-es6
" => vim-jsx
" git clone https://github.com/mxw/vim-jsx.git ~/.vim/bundle/vim-jsx
" => vim-styled-components
" git clone https://github.com/styled-components/vim-styled-components ~/.vim/bundle/vim-styled-components
" => nikvdp/ejs-syntax
" git clone https://github.com/nikvdp/ejs-syntax.git ~/.vim/bundle/ejs-syntax
" => typescript-vim
" git clone https://github.com/leafgarland/typescript-vim.git ~/.vim/bundle/typescript-vim
"
"
:highlight DiffDelete ctermfg=black ctermbg=green
:highlight DiffAdd ctermfg=black ctermbg=red
:highlight DiffChange ctermfg=black ctermbg=blue
:highlight DiffText ctermfg=black ctermbg=red
"
"
" faster up / down navigation
nnoremap L 8
vnoremap L 8
nnoremap H 8
vnoremap H 8
" resize window
nnoremap :res -2
nnoremap :res +2
nnoremap :vertical res -4
nnoremap :vertical res +4
" quickly switch to a window
nnoremap k k
nnoremap ˚ k
nnoremap j j
nnoremap ∆ j
nnoremap h h
nnoremap ˙ h
nnoremap l l
nnoremap ¬ l
" quicky close window without saving changes
nnoremap :q!
" quickly type a shell command
nnoremap ! :!
nnoremap :!./node_modules/.bin/
" quickly refresh the file
nnoremap :e
" go to the Nth symbol in line
nnoremap T 077lbh
"
"
set tabstop=2
set shiftwidth=2
nnoremap m :m .+1
nnoremap µ :m .+1
nnoremap , :m .-2
nnoremap ≤ :m .-2
vnoremap m :m '>+1gv
vnoremap µ :m '>+1gv
vnoremap , :m '<-2gv
vnoremap ≤ :m '<-2gv
"
"
comclear
" jump to Vim and Bash configs (rc files)
command! -nargs=0 B tabe ~/.bash/.bashrc
command! -nargs=0 V tabe ~/.vim/.vimrc
" project
command! -nargs=0 Eslint w|!echo =======Eslint======; npm run eslint
command! -nargs=0 Sasslint w|!echo =======Sasslint======; npm run sasslint
command! -nargs=* -complete=shellcmd Rex execute "new | r! "
" open netrw windo in vertical split but not in current window
command! -nargs=0 VEX :vs|:Ex|:execute "normal! \r"
command! -nargs=0 HEX :sp|:Ex|:execute "normal! \r"
" Git of my commits only
command! -nargs=0 Gmy Gitv --author="Oleh-Matviiv"
"
"
set hlsearch
" general search function
function! Fs(searchstr, path)
let @/ = a:searchstr
execute "tabe\|:lv /" . a:searchstr . "/ " . a:path
lw
endfunction
" jump to file function
function! JumpToFile(extension, fileNamePattern)
execute Fs("\." . a:fileNamePattern . "'", "./" . a:fileNamePattern . "\." . a:extension)
endfunction
" F6 - jump to file
nnoremap :execute JumpToFile("js", "src/**/
" search for visually selected string
function! SearchVisualSelection(extension)
let a_save = @a
normal! gv"ay
echo "Searching for '" . @a . "' in '*." . a:extension . "' files."
execute Fs(@a, "./**/" . "./src/**/*." . a:extension)
endfunction
" F7 - search for a string (normal and visual mode)
nnoremap :execute Fs(expand(""), "./src/**/*.js")
vnoremap :call SearchVisualSelection("js")
" // (in visual) - to quickly search for highlighted text
vnoremap // y/"
" quickly replace all occurances of visually selected string
function! ReplaceVisualSelection(withthis)
let a_save = @a
normal! gv"ay
execute "\%s\/" . @a . "\/" . a:withthis . "\/gc"
endfunction
vnoremap Ro :call ReplaceVisualSelection("
"
"
setlocal foldmethod=manual
:hi Folded ctermbg=8 ctermfg=7
set foldtext=MyFoldText() " nice folding
function! MyFoldText()
let line = getline(v:foldstart)
if match( line, '^[ \t]*\(\/\*\|\/\/\)[*/\\]*[ \t]*$' ) == 0
let initial = substitute( line, '^\([ \t]\)*\(\/\*\|\/\/\)\(.*\)', '\1\2', '' )
let linenum = v:foldstart + 1
while linenum < v:foldend
let line = getline( linenum )
let comment_content = substitute( line, '^\([ \t\/\*]*\)\(.*\)$', '\2', 'g' )
if comment_content != ''
break
endif
let linenum = linenum + 1
endwhile
let sub = initial . ' ' . comment_content
else
let sub = line
let startbrace = substitute( line, '^.*{[ \t]*$', '{', 'g')
if startbrace == '{'
let line = getline(v:foldend)
let endbrace = substitute( line, '^[ \t]*}\(.*\)$', '}', 'g')
if endbrace == '}'
let sub = sub.substitute( line, '^[ \t]*}\(.*\)$', '...}\1', 'g')
endif
endif
endif
let n = v:foldend - v:foldstart + 1
let info = " " . n . " lines"
let sub = sub . "
let num_w = getwinvar( 0, '&number' ) * getwinvar( 0, '&numberwidth' )
let fold_w = getwinvar( 0, '&foldcolumn' )
let sub = strpart( sub, 0, winwidth(0) - strlen( info ) - num_w - fold_w - 1 )
return sub . info
endfunction
"