vim Emacs - sgml/signature GitHub Wiki
- sudo apt-get install vim-gui-common
set nocompatible " set nocompatible fixes arrow keys in insert mode set backspace=indent,eol,start " set backspace fix backspace in normal mode set bs=2 " set bs fixes backspace in insert mode set autoindent " set autoindent preseves indentation when pasting text set exrc set fileformats=unix,dos,mac nmap k nmap j nmap h nmap l imap
To register the Vim script with Vim, follow these steps:
-
Save the Script: Save the Vim script (the one I provided earlier) to a file with a .vim extension. For example, you can save it as
fstring_conversion.vim
. -
Open Vim: Open Vim by running vim in your terminal.
-
Edit Your .vimrc File: Add the following line to your
~/.vimrc
:source /path/to/your/fstring_conversion.vim
-
Replace
/path/to/your/fstring_conversion.vim
with the actual path to the script file. -
Reload Your .vimrc:
-
After saving the changes to your
.vimrc
file, reload it in Vim by typing::source ~/.vimrc
-
Open your Python file in Vim.
-
Place the cursor on the line with the f-string you want to convert.
-
execute the call command with the name of the function:
:call ConvertFStringToPercentOperator()
" Find variables within f-strings and rewrite using '%' function! ConvertFStringToPercentOperator() let l:line_number = 1 while l:line_number <= line('$') let l:line = getline(l:line_number) if l:line =~# "print(f'\([^']*\)')" let l:variable_name = matchstr(l:line, "'\([^']*\)'") let l:replacement = printf("'%s: %%s'", l:variable_name) let l:line = substitute(l:line, "'\([^']*\)'", l:replacement, "") call setline(l:line_number, l:line) endif let l:line_number += 1 endwhile endfunction
" Open the file edit path/to/your/file.txt " Search for f-strings and replace them %s/print(f'\([^']*\): \({[^}]*}\)')/print("\1: %s", \2)/g " Save and close the file wq
Run it as follows:
vim -c 'source example.vim' -c 'qa'
Delete between quotes: d/' + enter
Delete all blank lines: g/^$/d
Delete without copying: _d + d or the number of lines
Delete the first character from diff formatted code: :1,$ s/^[+]//g
To Search for all line beginnings and replace them with a single quote, do the following: :%s/^/'/g
Insert p tags into blank lines: :1,$ s/^$/
\n/g
- Place the cursor on the tag.
- Enter visual mode by pressing v then press eiter a+t or i+t for the outer/inner tag.
- Press o or O to jump between the tags.
C-h b
- https://stackoverflow.com/questions/1050640/how-to-stop-vim-from-adding-a-newline-at-end-of-file
- https://askubuntu.com/questions/284957/vi-getting-multiple-sorry-the-command-is-not-available-in-this-version-af
- https://media.readthedocs.org/pdf/vimguide/latest/vimguide.pdf
- https://kb.iu.edu/search?q=vi+editor&s=15
- https://vimconfig.com/
- https://gist.github.com/simonista/8703722
- https://chrisyeh96.github.io/2017/12/18/vimrc.html
- http://vimdoc.sourceforge.net/htmldoc/vimfaq.html
- https://github.com/iggredible/Learn-Vim/blob/master/ch28_vimscript_functions.md
- https://public.dhe.ibm.com/software/dw/linux/l-vim-script-2/l-vim-script-2-pdf.pdf
- https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf
- https://www.gnu.org/software/emacs/manual/html_node/emacs/Misc-Help.html
- https://www.linux.com/news/turn-vim-bash-ide/
- http://blog.dreasgrech.com/2010/06/vims-black-hole-register.html
- https://www.brianstorti.com/vim-registers/
- http://vimdoc.sourceforge.net/htmldoc/usr_41.html#script
- http://vimdoc.sourceforge.net/htmldoc/usr_05.html
- https://github.com/isaacs/.vim/blob/master/macros/matchit.txt
- https://vi.stackexchange.com/questions/780/how-to-jump-between-matching-html-xml-tags
- https://vi.stackexchange.com/questions/10939/how-to-see-if-a-plugin-is-active
- https://vi.stackexchange.com/questions/2791/how-to-design-a-command-in-a-plugin-that-can-be-called-from-vimrc
- https://stackoverflow.com/questions/500989/jump-to-matching-xml-tags-in-vim
- https://everythingsysadmin.com/2010/09/a-powerful-vim-command-i-never.html
- https://www.reddit.com/r/vim/wiki/vimrctips
- https://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim/VimL_Script_language
- https://blog.semanticart.com/2017/01/05/lets-write-a-basic-vim-plugin/
- https://www.slideshare.net/ZendCon/vim-for-php-programmers-presentation
- https://www.vim.org/scripts/script.php?script_id=4454
- http://www.snowfrog.net/2009/01/08/vim-modelines/
- https://github.com/jonathanslenders/pyvim
- https://pmihaylov.com/tmux-terminal-multiplexer/
- https://www.systutorials.com/1419/vim-formatting-cc-code/
- http://aokolish.me/blog/2015/03/31/correcting-indentation-in-vim/
- https://alexkitchens.net/2016/10/03/vim-tabs-maps-more.html
- https://wincent.com/wiki/Vim_cheatsheet
- http://www.softpanorama.org/Editors/vim.shtml
- http://www.panozzaj.com/blog/2011/09/09/vim-directory-structure/
- https://unix.stackexchange.com/questions/7823/compiling-code-from-vim
- http://learnvimscriptthehardway.stevelosh.com/
- https://github.com/neovim/neovim/blob/master/runtime/doc/api.txt
- https://lamsh.github.io/slide/2017/20171104_VimConf2017/index.html
- https://blog.codepen.io/2014/02/21/vim-key-bindings/
- https://superuser.com/questions/713413/vim-how-to-delete-a-vim-buffer-when-you-quit-a-file-in-vim
- https://news.ycombinator.com/item?id=15321850
- https://www.ibm.com/developerworks/xml/library/x-emacs/