Advertisement
Guest User

vim termux fixes

a guest
Oct 10th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 1.54 KB | None | 0 0
  1. " encoding fix, for russian, hopefuly universal
  2. set enc=utf-8
  3. set fileencoding=utf-8
  4. set fileencodings=ucs-bom,utf8,prc
  5. set guifont=Monaco:h11
  6. set guifontwide=NSimsun:h12
  7.  
  8. " indent fix, tab shown as 1 space, pc-friendly
  9. set nocindent
  10. set nosmartindent
  11. set nosmarttab
  12. set noexpandtab
  13. set shiftwidth=1
  14. set softtabstop=1
  15. set tabstop=1
  16. set ignorecase
  17. filetype indent off
  18.  
  19. " fix for navigation like in all other editors
  20. nnoremap <expr> <Up> (v:count == 0 ? 'gk' : 'k')
  21. nnoremap <expr> <Down> (v:count == 0 ? 'gj' : 'j')
  22. inoremap <expr> <silent> <Up>   pumvisible() ? "\<Up>" : "\<C-o>gk"
  23. inoremap <expr> <silent> <Down> pumvisible() ? "\<Down>" : "\<C-o>gj"
  24. set whichwrap+=<,>,h,l,[,],b,s
  25. nnoremap f gg=G
  26.  
  27. " copy-paste fix. also do both:
  28. " pkg install termux-api
  29. " google play download 'termux api'
  30. nnoremap <C-c> :'<,'>w !termux-clipboard-set<CR>
  31. nnoremap <C-v> :r !termux-clipboard-get<CR>
  32.  
  33. " text and code folding, no special symbols
  34. " 1 new line = same foldlevel
  35. " 2 new lines = increase foldlevel
  36. " 3 new lines = decrease foldlevel
  37. let b:ind=0
  38. let b:progress=0
  39. let b:newlines=0
  40. set foldmethod=expr
  41. set foldexpr=VimFoldLevel(v:lnum)
  42. function! VimFoldLevel(line)
  43.     if(b:progress<=a:line)
  44.         let b:progress=a:line else return endif
  45.     if getline(a:line) =~ '^[ \t]*$'
  46.         let b:newlines=b:newlines+1
  47.         if b:newlines==2
  48.             return b:ind+1
  49.         endif
  50.         if b:newlines==3
  51.             let b:ind=max([b:ind-1,0])
  52.         endif
  53.         return b:ind
  54.     else   
  55.         if b:newlines==2
  56.             let b:ind=b:ind+1
  57.         endif
  58.         let b:newlines=0
  59.         return b:ind+1
  60.     endif
  61. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement