Showing posts with label Editores. Show all posts
Showing posts with label Editores. Show all posts

Saturday, December 2, 2023

Friday, November 10, 2023

Vim search for the escaped string of a line


command! -nargs=1 SH let @/ = '\V'.escape(<q-args>, '\')|set hlsearch

nnoremap <C-y> _vg_y<Esc>:SH <C-r>"<CR>


_    go to first non-space character in line

g_   go to last non-space character in line

v    start visual selection

y     copy selection

<C-r>" paste copied selection 

Saturday, August 26, 2023

Fuzzy Finder FZF with Syntax Highlight Preview

FZF is nice cli program that allow quick file navigation that find files as you type.

BAT is nice replacement for cat with highlight features

sudo apt install fzf

sudo apt install bat

Using fzf together with batcat to source code files and preview it with syntax highlight

fzf --preview 'batcat --style=numbers --color=always --line-range :500 {}'


.bashrc

source /usr/share/doc/fzf/examples/key-bindings.bash


if type rg &> /dev/null; then

  export FZF_DEFAULT_COMMAND='rg --files'

  export FZF_DEFAULT_OPTS='-m --height 50% --border'

fi


alias findz="fzf --preview 'batcat --style=numbers --color=always --line-range :500 {}'"


_fzf_comprun() {

  local command=$1

  shift


  case "$command" in

    cd)           fzf --preview 'tree -C {} | head -200'   "$@" ;;

    export|unset) fzf --preview "eval 'echo \$'{}"         "$@" ;;

    ssh)          fzf --preview 'dig {}'                   "$@" ;;

    *)            fzf --preview 'batcat -n --color=always {}' "$@" ;;

  esac

}

export FZF_CTRL_R_OPTS="

  --preview 'echo {}' --preview-window up:3:hidden:wrap

  --bind 'ctrl-/:toggle-preview'

  --bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'

  --color header:italic

  --header 'Press CTRL-Y to copy command into clipboard'"


export FZF_ALT_C_OPTS="--preview 'tree -C {}'"


Usage:

vim $(fzf)

Ctrl+R   # open command history

Alt+C   # show directories and cd to it

Vim **<tab>  #open file list and open with vim

cd **<tab> # open directory list and cd to it


(fzf.vim) .vimrc

command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1, {'options': '--delimiter : --nth 4..'}, <bang>0)

set grepprg=rg\ --vimgrep\ --smart-case\ --follow

command! -bang -nargs=? -complete=dir Files

    \ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/bundle/fzf.vim/bin/preview.sh {}']}, <bang>0)

"Open Files in the bottom

"let g:fzf_layout = { 'up':  '40%'}

"let g:fzf_layout = { 'down':  '40%'}

Monday, October 17, 2022

Show a vertical column markers in vim (very usefull to check identation)

To show a background line in the whole column 9 and 17

:set colorcolumn=9,17
or short
:set cc=9,17

To change the color to blue
:highlight ColorColumn ctermbg=blue


show line in the cursor column
exe 'set cc='.col('.')
Source: https://superuser.com/questions/249779/how-to-setup-a-line-length-marker-in-vim-gvim

Friday, July 1, 2022

Vim find and repeat search

 For example,

use

f<space>  to go to the next space

; to repeat search and go to the othe next space;


f(  find next (

;;;  go to the fourth ( 

Saturday, June 19, 2021

Tuesday, February 9, 2021

Open an Online Development Enviroment in a container with the git repository code

https://www.gitpod.io/


Open your browser with addres like this

gitpod.io/#type_here_the_git(hub/lab/bitbucket)url

...............................................
https://codeanywhere.com/

...............................................
https://azure.microsoft.com/pt-br/services/visual-studio-online/
...............................................

https://codesandbox.io/
...............................................

https://online.visualstudio.com/
...............................................

https://analyticsindiamag.com/top-8-alternatives-of-github-codespaces/
...............................................

github1s

for example to access this repo inside Visual Studio Editor
https://github.com/Spiderpig86/Cirrus.
replace github.com by github1s.com
https://github1s.com/Spiderpig86/Cirrus.


For arduino 
https://codebender.cc/


Saturday, June 20, 2020

Execute Comand in normal mode in all lines of the file


For example to add the word thiago in the end of all lines of a file
:%normal Athiago


Other Example

To remove, second names from all lines

Joana Dack
Ada Lovelace
Fabia Carla

:%normal WhD

To remove middle name

Joana Dack Silva
Ada Lovelace Silva
Fabia Carla Silva

:%normal Wdw

Grep lines on VIM

Thiago Masaki
Joana Dark
Fulando Masaki
Siclano de tal


:g/Masaki    - show lines which contains Masaki


:g/Masaki/d  - delete  lines which contains Masaki

Insert text in block based on first line

For example

Name: Ana
Bia
Carol
Dani
Elza
Fabi

Ctr+v  - to enter block selection
j  until reach Fabi

shift + i

Start typing
Ctrl + y 
It will type char by char the same characters from the previous line

Esc to complete all lines


Or to append text from clipboard in the end of a block

Ctrl+v
j until reach Fabi
$  - to block selection go to the end of the line
A - to enter append mode

Ctr+r, "

Spell Checker and Dictionary search in VIM

:set spell
:set spelllang=pt_br

Vim start highlighting wrong senteces in the language selected


Start typed a word for example
paral
Ctrl+x, Ctr+k         - This will open menu with word of the dictionary


Navigate in wrong words, 
[s    -   backwards
 ]s    -  forward

Show possible fix to the current wrong word
 z=


If  you have two splits or buffer set for only one buffer or split

:setlocal  spell spelllang=en_us


to disable

:set nospell

Friday, June 19, 2020

Vim Show lines relative to the cursor position


:set relativenumber




It is useful when you want to delete a block of lines, quickly without entering in visual mode and selecting 

For example, 
To delete lines Setima Linha (0) until  Nona Linha (2) , just type:
 d 2 j

To delete lines from Setima Linha (0) until Segunda Linha (5), just type:
 d 5 k

Tuesday, May 26, 2020

TMUX

.tmux.conf

source /usr/share/powerline/bindings/tmux/powerline.conf
set -g mouse on
set -g history-limit 30000

For the mouse work properly using Vim inside Tmux

In your .vimrc add:

set ttymouse=xterm2
set mouse=a


Atalhos TMUX

set -g status off

Type in all panes at same time
ctrl + b   : setw synchronize-panes on

ctrl + b z   maximize current pane

ctr + b t    show a clock, it can be used to ignore typing when in syncronize-panes on

Ctrl+b " — split pane horizontally.
Ctrl+b % — split pane vertically.
Ctrl+b arrow key — switch pane.
Hold Ctrl+b, don’t release it and hold one of the arrow keys — resize pane.
Ctrl+b c — (c)reate a new window.
Ctrl+b n — move to the (n)ext window.
Ctrl+b p — move to the (p)revious window.
Other thing worth knowing is that scrolling is enabled by
Ctr+b  Alt (arrow)  - resize
          Repeat Alt(arrow) - resize more times
Ctr+b Esc (arrow)  - resize
          Repeat Alt(arrow) - resize more times
Ctr+b Option (arrow)  - resize
          Repeat Option(arrow) - resize more times

C-b [    Start scroll mode, so press Arrow up or Page up

q   Exit scroll mode

C-b x          kill the current pane

C-b q          display pane numbers for a short while

C-b {          move the current pane to the previous position
C-b }          move the current pane to the next position
C-b C-o        rotate window ‘up’ (i.e. move all panes)
C-b M-o        rotate window ‘down’
C-b !          move the current pane into a new separate
               window (‘break pane’)
C-b :move-pane -t :3.2
               split window 3's pane 2 and move the current pane there


C-b c          create a new window
Switch between windows:
C-b 1 ...      switch to window 1, ..., 9, 0
C-b 9
C-b 0
C-b p          previous window
C-b n          next window
C-b l          ‘last’ (previously used) window
C-b w          choose window from a list

Disable bell in Vim, Bash

Disable bell in bash autocompletion


/etc/inputrc

 set bell-style none


 Disable bell when pressing ESC in Vim

 ~/.vimrc

set visualbell

Blog Archive