Is it possible to run sed interpreter script "in place" (-i)?
#!/usr/bin/sed -if
#sed commands...
This gives me the following error:
/usr/bin/sed: -e expression #1, char 7: unknown command: `f'
I have tried to search for it but I've found only #!/usr/bin/sed -nf (which for some reason works fine).
BTW: I know I could run bash script and the sed -i command, but it just doesn't feel right :D
EDIT:
I'm just correcting some JSON config file. Using python JSON parser removes all formatting and comments(!) so that isn't working for me. I have tried all possible combinations of sed -i -f sed -f -i etc.
EDIT:
For those unbelievers: Here is the whole script. Hope you like it :D
#!/usr/bin/sed -if
# Tabs - change height
/\/\/ Tab set/,/\}\,/ {
s/"tab_width": .*,/"tab_width": 50,/;
s/"tab_height": .*,/"tab_height": 27,/;
}
# VScroll bar
/\/\/ Overlay vertical puck/,/\}\,/ {
# Width
s/"content_margin": .*/"content_margin": [3,38],/
# Color
/content_margin/ {
a\
"layer0.tint":[173,216,230],
a\
"layer0.opacity": 0.2,
}
}
# HScroll bar - width
/\/\/ Overlay horizontal puck/,/\}\,/ {
s/"content_margin": .*/"content_margin": [16,3],/
}
# Status bar - height
/\/\/ Status bar container/,/\}\,/ {
s/"content_margin": .*/"content_margin": [15, 4]/
}
# Side bar - rows
/\/\/ Sidebar tree || entries/,/\}\,/ {
s/"row_padding": .*/"row_padding": [8,5],/
s/"indent_offset": .*/"indent_offset": 10,/
}
# Side bar - folder icon
/\/\/ Sidebar folder opened/,/\}\,/ {
s/"layer0.texture": "Seti_UI\/icons\/folder_open#2x.png",/"layer0.texture": "Seti_UI\/icons\/folder#2x.png",/
}
According to this answer on unix.stackexchange, this will not work because it is not (portably) possible to use more than one argument on a #! line. The answer comes with acceptable (at least, to me) workarounds.
Related
help terminal-input said
To use `ALT+{h,j,k,l}` to navigate windows from any mode: >
:tnoremap <A-h> <C-\><C-N><C-w>h
:tnoremap <A-j> <C-\><C-N><C-w>j
:tnoremap <A-k> <C-\><C-N><C-w>k
:tnoremap <A-l> <C-\><C-N><C-w>l
:inoremap <A-h> <C-\><C-N><C-w>h
:inoremap <A-j> <C-\><C-N><C-w>j
:inoremap <A-k> <C-\><C-N><C-w>k
:inoremap <A-l> <C-\><C-N><C-w>l
:nnoremap <A-h> <C-w>h
:nnoremap <A-j> <C-w>j
:nnoremap <A-k> <C-w>k
:nnoremap <A-l> <C-w>l
.
Thus I add these shortcut maps into my init file. And when a terminal is open, i type <A-j>, the cursor jumped from the terminal into the normal interface (The terminal interface does not close.). i want jump back to the terminal interface. However, all the shortcuts do not work. They only jump across windows.
:) i wanted the same thing i searched online to learn how to write a custom function around buffers, then came with this:
function SwitchToTerm()
let term_bufs = getbufinfo({'buflisted':1})
let curr_buf = bufnr('%')
call filter(term_bufs, 'v:val.name =~ "^term"')
call filter(term_bufs, 'v:val.bufnr != ' . curr_buf)
call map(term_bufs, { _, e -> ({"nr": e.bufnr, "lu": e.lastused}) })
if bufname('%') =~ "^term"
call sort(term_bufs, { b1, b2 -> b1.lu - b2.lu })
else
call sort(term_bufs, { b1, b2 -> b2.lu - b1.lu })
endif
exec "b " . term_bufs[0].nr
endfunction
nnoremap <silent> <Leader>t :call SwitchToTerm()<cr>
in my ~/.vimrc and using Neovim but not sure if that matters. It is supposed to go to the most recently used buffer, then continuously cycle through terminal buffers if already on at a terminal. I switch to BufExplorer a lot to visit another file, and the last terminal becomes iffy there... but switching buffers directly from the command line works fine.
I'm using neovim and Telescope as a finder (find_files, live_grep, file_browser), by default Telescope is ignoring hidden files and files included in .gitignore - how can I add exception (e.g. .gitlab-ci file/folder) to this list? so Telescope will still ignore hidden files except .gitlab-ci file/folder?
Use default filter ignore pattern for that like that
telescope.setup {
....
defaults = {
....
file_ignore_patterns = {
"node_modules", "build", "dist", "yarn.lock"
},
}
}
I know you can find this in someone's vimrc files or telescope docs. But may help some newbies.
Telescope uses ripgrep to search through files. By default, ripgrep ignores several groups of files, including hidden files (dotfiles) and files ignored by git. Adding --no-ignore-vcs and --hidden flags will make it to search through those files.
Arguments for ripgrep can be configured via defaults.vimgrep_arguments.
In your case, to search through hidden files, which are not in .gitignore --hidden flag should be added:
require('telescope').setup{
defaults = {
vimgrep_arguments = {
'rg',
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
'--smart-case',
'--hidden',
},
}
You can always test the command from the terminal before changing the Telescope configuration:
rg ... --hidden <search string>
As --hidden will enable search through all hidden files, you might want to look into .ignore or .rgignore files. They tell ripgrep which files to ignore during search. See ripgrep's documentation for more info.
After several weeks of intense reading and testing, I have found the for me easiest solution here.
In order to find HIDDEN FILES, I have added the following lines to
.config/nvim/init.vim
nnoremap fff <cmd>Telescope find_files <cr>
nnoremap ffh <cmd>Telescope find_files hidden=true<cr>
When yo launch Neovim UI, pressing fff pops up the Telescope find_file screen, and when you press ffh, you can search for HIDDEN files.
To search for hidden files in LIVE_GREP, the work was a bit more difficult.
From my perspective, the most elegant solution is to first create the following file : .config/nvim/lua/find_hidden.lua
Inside goes :
local telescope = require("telescope")
local telescopeConfig = require("telescope.config")
-- Clone the default Telescope configuration
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
-- I want to search in hidden/dot files.
table.insert(vimgrep_arguments, "--hidden")
-- I don't want to search in the `.git` directory.
table.insert(vimgrep_arguments, "--glob")
table.insert(vimgrep_arguments, "!**/.git/*")
telescope.setup({
defaults = {
-- `hidden = true` is not supported in text grep commands.
hidden = true,
vimgrep_arguments = vimgrep_arguments,
},
pickers = {
find_files= {
hidden = true,
-- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
},
},
})
----- This activates the search for hidden files in live_grep
require("telescope").setup {
pickers = {
live_grep = {
additional_args = function(_ts)
return {"--hidden"}
end
},
},
}
The add the following the following lines to your init.vim :
:lua require('find_hidden')
nnoremap gre <cmd>Telescope live_grep <cr>
To sum it up: with the find_hidden.lua file and the following lines in your init.vim, you can easily search for hidden and non-hidden files both in telescope_find_files and telescope_live_grep :
:lua require('find_hidden')
nnoremap fff <cmd>Telescope find_files <cr>
nnoremap ffh <cmd>Telescope find_files hidden=true<cr>
nnoremap gre <cmd>Telescope live_grep <cr>
I am trying flutter_markdown package to markdown some content. But it is not working properly for multiple line breaks.
String exampleData="\n\nLine 1. \n\nLine2.\n\n\n\n### Heading \n\nLine3";
Markdown(data: exampleData,)
The output is
I tried with line breaks "<br />" but it didn't worked
String exampleData="Line 1. \n\nLine2. <br /> <br /> \n\n### Heading \n\nLine3";
Out put is
Can someone help me with this line breaks or any alternative packages.
check out below link!!
enter link description here
br tag is not working, so using 3 back slash + n instead of br tag
String exampleData="Line 1. \\\nLine2. \\\n## Heading \\\nLine3";
I've found a nasty trick (not a solution) that may be of help in this specific case. I don't recommend it, but couldn't find any other workaround using flutter_markdown so far, and I couldn't find any other package in substitution neither.
You can take advantage of using triple apostrophes to add vertical space.
It is a nasty workaround, but couldn't find anything better so far to add vertical space.
Replace your <br> with \x03 like this. \x03 is End of text(ETX) in ASCII:
text.replaceAll('<br>', '\x03');
A decent Work Around.
A new feature is added in Flutter_markdown package called paddingBuilders , from version 0.6.8. you can add padding to all of the blocks available in markdown like below.
MarkdownBody(
data: markDown,
paddingBuilders: <String,
MarkdownPaddingBuilder>{
'p': PPaddingBuilder(),
'h3': H3PaddingBuilder(),
},
)
where you have to define the padding builder like below.
class PPaddingBuilder extends MarkdownPaddingBuilder {
#override
EdgeInsets getPadding() => const EdgeInsets.only(top: SGSpacing.xlarge);
}
class H3PaddingBuilder extends MarkdownPaddingBuilder {
#override
EdgeInsets getPadding() => const EdgeInsets.only(top: SGSpacing.xxlarge);
}
The list of all blockTag available in Flutter_markdown from source code is below:
const List<String> _kBlockTags = <String>[
'p',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'li',
'blockquote',
'pre',
'ol',
'ul',
'hr',
'table',
'thead',
'tbody',
'tr'
];
PS: padding will not work for inline Tags. only block Tag applicable.
Hi I found this package https://pub.dev/packages/markdown_widget
It's not a completely solution but this package support some tags os html like <\br>, in this case I added that tag in the markdown and works
My solution, when use String single line, not use """ or ''', use \n with 2 space
Below code show same UI
var _markdownSingleLine = 'Demo \n Break \n line';
var _markdownMultiLine =
'''
Demo
Break
line
''';
Demo break line
According to a now deleted issue, flutter_markdown supports explicit line breaks using a backslash at the end of the line. Using this syntax, your example would be:
\
\
Line 1.\
\
Line2.\
\
\
\
### Heading
\
Line3
Just add '
\
u2028' for line breaks.
This is the Unicode Character 'LINE SEPARATOR'
In a normal buffer of nvim, the following ex command works.
:normal! GAabcd
This adds the text "abcd" to the current normal buffer.
But in a terminal buffer of nvim, the above ex command doesn't work!
:normal! GAabcd
This just converts the terminal buffer into '-- TERMINAL --' mode and the "abcd" isn't added!
Why isn't the text added? How can I accomplish that?
I digged the neovim sources and maybe found the answer by myself.
In edit funtion of edit.c, there is the following comment.
bool edit(int cmdchar, bool startln, long count)
{
if (curbuf->terminal) {
if (ex_normal_busy) {
// Do not enter terminal mode from ex_normal(), which would cause havoc
// (such as terminal-mode recursiveness). Instead set a flag to force-set
// the value of `restart_edit` before `ex_normal` returns.
restart_edit = 'i';
force_restart_edit = true;
} else {
terminal_enter();
}
return false;
}
...
I think it means that it's not possible to enter terminal mode(insert mode) while processing normal commands in ex-mode. Therefore the text 'abcd' wasn't added in terminal mode but was just processed as normal commands.
Your answer is correct in that it's not possible to append text using :normal! GAfoo. However, in the interests of answering your last question, you can do this:
:normal! "0p
So if you happen to have what you need in a register, you can always paste it.
BTW, this is not asking how to format code in VS, or the keybinding, so please don't mark it duplicate of this. It is specifically about formatting during typing.
Given the following code:
if(true) {
console.log('hello');
console.log('world');
}
If I go to the end of the 'log hello' line, hit DEL to bring 'log world' to the end of the line I will get (with | representing my cursor):
if(true) {
console.log('hello');| console.log('world');
}
Now, if I hit ENTER, I will get:
if(true) {
console.log('hello');
| console.log('world');
}
In other editors I would expect the white space to be 'eaten up' and the line to be reformatted, looking like this again:
if(true) {
console.log('hello');
|console.log('world');
}
Any thoughts on how to change this behavior?
This would also (hopefully) handle the pasting in of code that was not properly formatted, for instance, if I wanted to paste the following in:
console.log('arrrgg');
console.log('matey');
To the end of the if, I would see:
if(true) {
console.log('hello');
console.log('world');
console.log('arrrgg');
console.log('matey');
}
Instead of:
if(true) {
console.log('hello');
console.log('world');
console.log('arrrgg');
console.log('matey');
}
Certainly, I can hit Shift-Alt-F and reformat, but I don't always want to reformat an entire file....
I think I have been spoiled with VS and WebStorm automatically cleaning up and reformatting code quickly. Not sure if that is a valid
Is this even possible in Code?